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


Java Jedis.select方法代碼示例

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


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

示例1: lock

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public String lock(String key) {
    Jedis jedis = null;
    try {
        jedis = redisConnection.getJedis();
        jedis.select(dbIndex);
        key = KEY_PRE + key;
        String value = fetchLockValue();
        if (SET_SUCCESS.equals(jedis.set(key, value, "NX", "EX", lockExpirseTime))) {
            log.debug("Reids Lock key : " + key + ",value : " + value);
            return value;
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (jedis != null) {
            jedis.close();
        }
    }
    return null;
}
 
開發者ID:gaochao2000,項目名稱:redis_util,代碼行數:21,代碼來源:LockServiceRedisImpl.java

示例2: expire

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public boolean expire(String key, int expireSecond) {
    log.trace("strar set expire " + key);
    Jedis jedis = null;
    try {
        jedis = redisConnection.getJedis();
        jedis.select(dbIndex);
        return jedis.expire(key, expireSecond) == 1;
    } catch (Exception e) {
        log.warn(e.getMessage(), e);
    } finally {
        if (jedis != null) {
            jedis.close();
        }
    }
    return false;
}
 
開發者ID:gaochao2000,項目名稱:redis_util,代碼行數:17,代碼來源:CacheServiceRedisImpl.java

示例3: clear

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public void clear() throws CacheException {
	Jedis jedis = null;
	try
	{
		jedis = redisManager.getJedis();
    	jedis.select(DB_INDEX);
    	jedis.flushDB();
	}finally
	{
		if(null != jedis)
		{
			jedis.close();
		}
	}
	
	
	
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:20,代碼來源:RedisShiroCache.java

示例4: delByMapKey

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 刪除Map裏的值
 * @param mapKey
 * @param dkey
 * @return
 */
public Object delByMapKey(String mapKey ,String...dkey) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		byte[][] dx = new byte[dkey.length][];
		for (int i = 0; i < dkey.length; i++) {
			dx[i] = dkey[i].getBytes();
		}
		Long result = jds.hdel(mapKey.getBytes(), dx);
		return result;
	} catch (Exception e) {
		throw e;
	} finally {
		if(jds != null)
		{
			jds.close();
		}
	}
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:27,代碼來源:RedisManager.java

示例5: fetchDailyUUID

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public Long fetchDailyUUID(String key, Integer length, Boolean haveDay) {
    Jedis jedis = null;
    try {
        jedis = redisConnection.getJedis();
        jedis.select(dbIndex);
        Calendar now = new GregorianCalendar();
        String day = df.format(now.getTime());
        key = key + "_" + day;
        Long num = jedis.incr(key);
        //設置 key 過期時間
        if (num == 1) {
            jedis.expire(key, (24 - now.get(Calendar.HOUR_OF_DAY)) * 3600 + 1800);
        }
        if (haveDay) {
            return createUUID(num, day, length);
        } else {
            return num;
        }
    } finally {
        if (jedis != null) {
            jedis.close();
        }
    }
}
 
開發者ID:gaochao2000,項目名稱:redis_util,代碼行數:25,代碼來源:UUIDServiceRedisImpl.java

示例6: fetchUUID

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public Long fetchUUID(String key, Integer length, Boolean haveDay) {
    Jedis jedis = null;
    try {
        jedis = redisConnection.getJedis();
        jedis.select(dbIndex);
        Calendar now = new GregorianCalendar();
        Long num = jedis.incr(key);

        if (haveDay) {
            String day = df.format(now.getTime());
            return createUUID(num, day, length);
        } else {
            return num;
        }
    } finally {
        if (jedis != null) {
            jedis.close();
        }
    }
}
 
開發者ID:gaochao2000,項目名稱:redis_util,代碼行數:21,代碼來源:UUIDServiceRedisImpl.java

示例7: getValueByKey

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public byte[] getValueByKey(int dbIndex, byte[] key) throws Exception {
    Jedis jedis = null;
    byte[] result = null;
    try {
        jedis = getJedis();
        jedis.select(dbIndex);
        result = jedis.get(key);
    } catch (Exception e) {
        throw e;
    } finally {
    	if(null != jedis)
    	{
    		jedis.close();
    	}
    }
    return result;
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:18,代碼來源:RedisManager.java

示例8: getVByList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 往redis裏取set整個集合
 * 
 * @param <T>
 * @param setKey
 * @param start
 * @param end
 * @param requiredType
 * @return
 */
@SuppressWarnings("unchecked")
public <T> Set<T> getVByList(String setKey,Class<T> requiredType) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		Set<T> set = new TreeSet<T>();
		Set<byte[]> xx = jds.smembers(setKey.getBytes());
		for (byte[] bs : xx) {
			T t = SerializeUtil.deserialize(bs, requiredType);
			set.add(t);
		}
		return set;
	} catch (Exception e) {
		throw e;
	} finally {
		if(jds != null)
		{
			jds.close();
		}
	}
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:33,代碼來源:RedisManager.java

示例9: ttl

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public Long ttl(String key) {
    log.trace("get set expire " + key);
    Jedis jedis = null;
    try {
        jedis = redisConnection.getJedis();
        jedis.select(dbIndex);
        return jedis.ttl(key);
    } catch (Exception e) {
        log.warn(e.getMessage(), e);
    } finally {
        if (jedis != null) {
            jedis.close();
        }
    }
    return -2L;
}
 
開發者ID:gaochao2000,項目名稱:redis_util,代碼行數:17,代碼來源:CacheServiceRedisImpl.java

示例10: setVBySet

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 往redis裏存Set
 * @param setKey
 * @param value
 */
public void setVBySet(String setKey,String value) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		jds.sadd(setKey, value);
	} catch (Exception e) {
		throw e;
       } finally {
       	if(jds != null)
		{
			jds.close();
		}
       }
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:21,代碼來源:RedisManager.java

示例11: 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

示例12: setVByMap

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 
 * @param mapkey map
 * @param key	 map裏的key
 * @param value   map裏的value
 */
public  void setVByMap(String mapkey,String key ,Object value) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		byte[] svalue = SerializeUtil.serialize(value);
		jds.hset(mapkey.getBytes(), key.getBytes(),svalue);
       } catch (Exception e) {
       	throw e;
       } finally {
       	if(jds != null)
		{
			jds.close();
		}
       }
	
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:24,代碼來源:RedisManager.java

示例13: setex

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 過期時間的
 * @param key
 * @param value
 * @param timer (秒)
 */
public void setex(String key, Object value, int timer) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		byte[] svalue = SerializeUtil.serialize(value);
		jds.setex(key.getBytes(), timer, svalue);
       } catch (Exception e) {
           throw e;
       } finally {
       	if(jds != null)
		{
			jds.close();
		}
       }
	
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:24,代碼來源:RedisManager.java

示例14: available

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public boolean available(){
    Jedis jedis = getJedis();
    if(jedis!=null){
        jedis.select(0);
        String key = "[email protected]";
        jedis.set(key,"available");
        if("available".equals(jedis.get(key))){
            jedis.del(key);
            return true;
        }
    }else{
        return false;
    }
    return false;
}
 
開發者ID:Kuangcp,項目名稱:MythRedisClient,代碼行數:16,代碼來源:RedisPools.java

示例15: acquireConnection

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
protected Jedis acquireConnection() {
	Jedis jedis = connectionPool.getResource();

	if (getDatabase() != 0) {
		jedis.select(getDatabase());
	}

	return jedis;
}
 
開發者ID:appNG,項目名稱:appng-tomcat-session,代碼行數:10,代碼來源:RedisSessionManager.java


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