當前位置: 首頁>>代碼示例>>Java>>正文


Java Jedis.exists方法代碼示例

本文整理匯總了Java中redis.clients.jedis.Jedis.exists方法的典型用法代碼示例。如果您正苦於以下問題:Java Jedis.exists方法的具體用法?Java Jedis.exists怎麽用?Java Jedis.exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redis.clients.jedis.Jedis的用法示例。


在下文中一共展示了Jedis.exists方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setSet

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 設置Set緩存
 * @param key 鍵
 * @param value 值
 * @param cacheSeconds 超時時間,0為不超時
 * @return
 */
public static long setSet(String key, Set<String> value, int cacheSeconds) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			jedis.del(key);
		}
		result = jedis.sadd(key, (String[])value.toArray());
		if (cacheSeconds != 0) {
			jedis.expire(key, cacheSeconds);
		}
		logger.debug("setSet {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("setSet {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:28,代碼來源:JedisUtils.java

示例2: getMap

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取Map緩存
 *
 * @param key 鍵
 * @return 值
 */
public static Map<String, String> getMap(String key) {
	Map<String, String> value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			value = jedis.hgetAll(key);
			logger.debug("getMap {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("getMap {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:23,代碼來源:JedisUtils.java

示例3: getObjectList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取List緩存
 * @param key 鍵
 * @return 值
 */
public static List<Object> getObjectList(String key) {
	List<Object> value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(getBytesKey(key))) {
			List<byte[]> list = jedis.lrange(getBytesKey(key), 0, -1);
			value = Lists.newArrayList();
			for (byte[] bs : list){
				value.add(toObject(bs));
			}
			logger.debug("getObjectList {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("getObjectList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:26,代碼來源:JedisUtils.java

示例4: getSet

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取緩存
 * @param key 鍵
 * @return 值
 */
public static Set<String> getSet(String key) {
	Set<String> value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			value = jedis.smembers(key);
			logger.debug("getSet {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("getSet {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:22,代碼來源:JedisUtils.java

示例5: exists

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 判斷是否存在
 * @param existskey
 * @return
 */
public boolean exists(String existskey) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		return jds.exists(existskey.getBytes());
	} catch (Exception e) {
		throw e;
	} finally {
		if(jds != null)
		{
			jds.close();
		}
	}
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:21,代碼來源:RedisManager.java

示例6: setList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 設置List緩存
 *
 * @param key          鍵
 * @param value        值
 * @param cacheSeconds 超時時間,0為不超時
 * @return
 */
public static long setList(String key, List<String> value, int cacheSeconds) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			jedis.del(key);
		}
		result = jedis.rpush(key, (String[]) value.toArray());
		if (cacheSeconds != 0) {
			jedis.expire(key, cacheSeconds);
		}
		logger.debug("setList {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("setList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:29,代碼來源:JedisUtils.java

示例7: getObjectSet

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取緩存
 *
 * @param key 鍵
 * @return 值
 */
public static Set<Object> getObjectSet(String key) {
	Set<Object> value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(getBytesKey(key))) {
			value = Sets.newHashSet();
			Set<byte[]> set = jedis.smembers(getBytesKey(key));
			for (byte[] bs : set) {
				value.add(toObject(bs));
			}
			logger.debug("getObjectSet {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("getObjectSet {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:27,代碼來源:JedisUtils.java

示例8: addSignForMap

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public void addSignForMap(String map, ChatColor color, String template, RestrictedVersion restrictedVersion, Sign sign)
{
    GameSign gameSign = new GameSign(this.hub, this, map, color, template, restrictedVersion, sign);

    Jedis jedis = SamaGamesAPI.get().getBungeeResource();

    if (jedis != null && jedis.exists("hub:maintenance:" + this.getCodeName() + ":" + template))
        gameSign.setMaintenance(Boolean.valueOf(jedis.get("hub:maintenance:" + this.getCodeName() + ":" + template)));
    if (jedis != null && jedis.exists("hub:soon:" + this.getCodeName() + ":" + template))
        gameSign.setSoon(Boolean.valueOf(jedis.get("hub:soon:" + this.getCodeName() + ":" + template)));

    if (jedis != null)
        jedis.close();

    if (this.signs.containsKey(map))
    {
        this.signs.get(map).add(gameSign);
    }
    else
    {
        List<GameSign> list = new ArrayList<>();
        list.add(gameSign);

        this.signs.put(map, list);
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:27,代碼來源:AbstractGame.java

示例9: setObjectSet

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 設置Set緩存
 *
 * @param key          鍵
 * @param value        值
 * @param cacheSeconds 超時時間,0為不超時
 * @return
 */
public static long setObjectSet(String key, Set<Object> value, int cacheSeconds) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(getBytesKey(key))) {
			jedis.del(key);
		}
		Set<byte[]> set = Sets.newHashSet();
		for (Object o : value) {
			set.add(toBytes(o));
		}
		result = jedis.sadd(getBytesKey(key), (byte[][]) set.toArray());
		if (cacheSeconds != 0) {
			jedis.expire(key, cacheSeconds);
		}
		logger.debug("setObjectSet {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("setObjectSet {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:33,代碼來源:JedisUtils.java

示例10: setMap

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 設置Map緩存
 * @param key 鍵
 * @param value 值
 * @param cacheSeconds 超時時間,0為不超時
 * @return
 */
public static String setMap(String key, Map<String, String> value, int cacheSeconds) {
	String result = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			jedis.del(key);
		}
		result = jedis.hmset(key, value);
		if (cacheSeconds != 0) {
			jedis.expire(key, cacheSeconds);
		}
		logger.debug("setMap {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("setMap {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:28,代碼來源:JedisUtils.java

示例11: delObject

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 刪除緩存
 * @param key 鍵
 * @return
 */
public static long delObject(String key) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(getBytesKey(key))){
			result = jedis.del(getBytesKey(key));
			logger.debug("delObject {}", key);
		}else{
			logger.debug("delObject {} not exists", key);
		}
	} catch (Exception e) {
		logger.warn("delObject {}", key, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:24,代碼來源:JedisUtils.java

示例12: getList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取List緩存
 * @param key 鍵
 * @return 值
 */
public static List<String> getList(String key) {
	List<String> value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			value = jedis.lrange(key, 0, -1);
			logger.debug("getList {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("getList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:22,代碼來源:JedisUtils.java

示例13: get

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取緩存
 * @param key 鍵
 * @return 值
 */
public static String get(String key) {
	String value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			value = jedis.get(key);
			value = StringUtils.isNotBlank(value) && !"nil".equalsIgnoreCase(value) ? value : null;
			logger.debug("get {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("get {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:23,代碼來源:JedisUtils.java

示例14: exists

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public Boolean exists(String key) {
	Jedis jedis = jedisPool.getResource();
	Boolean result = jedis.exists(key);
	jedis.close();
	return result;
}
 
開發者ID:mmdsyl,項目名稱:BLOG-Microservice,代碼行數:8,代碼來源:JedisClientPool.java

示例15: exists

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 緩存是否存在
 *
 * @param key 鍵
 * @return
 */
public static boolean exists(String key) {
	boolean result = false;
	Jedis jedis = null;
	try {
		jedis = getResource();
		result = jedis.exists(key);
		logger.debug("exists {}", key);
	} catch (Exception e) {
		logger.warn("exists {}", key, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:21,代碼來源:JedisUtils.java


注:本文中的redis.clients.jedis.Jedis.exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。