本文整理匯總了Java中org.springframework.data.redis.connection.RedisConnection.close方法的典型用法代碼示例。如果您正苦於以下問題:Java RedisConnection.close方法的具體用法?Java RedisConnection.close怎麽用?Java RedisConnection.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.data.redis.connection.RedisConnection
的用法示例。
在下文中一共展示了RedisConnection.close方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doReadSession
import org.springframework.data.redis.connection.RedisConnection; //導入方法依賴的package包/類
protected Session doReadSession(Serializable sessionId) {
byte[] sessionKey = buildRedisSessionKey(sessionId);
RedisConnection redisConnection = getRedisConnection();
try {
byte[] value = redisConnection.get(sessionKey);
if (value == null) {
return null;
}
Session session = SerializeUtil.deserialize(value, SimpleSession.class);
return session;
} finally {
redisConnection.close();
}
}
示例2: delete
import org.springframework.data.redis.connection.RedisConnection; //導入方法依賴的package包/類
public void delete(Session session) {
if (session != null) {
Serializable id = session.getId();
if (id != null) {
RedisConnection redisConnection = getRedisConnection();
try {
redisConnection.del(buildRedisSessionKey(id));
} finally {
redisConnection.close();
}
}
}
}
示例3: getActiveSessions
import org.springframework.data.redis.connection.RedisConnection; //導入方法依賴的package包/類
public Collection<Session> getActiveSessions() {
List<Session> list = InstanceUtil.newArrayList();
RedisConnection redisConnection = getRedisConnection();
try {
Set<byte[]> set = redisConnection.keys((Constants.REDIS_SHIRO_SESSION + "*").getBytes());
for (byte[] key : set) {
list.add(SerializeUtil.deserialize(redisConnection.get(key), SimpleSession.class));
}
} finally {
redisConnection.close();
}
return list;
}
示例4: saveSession
import org.springframework.data.redis.connection.RedisConnection; //導入方法依賴的package包/類
private void saveSession(Session session) {
if (session == null || session.getId() == null) throw new UnknownSessionException("session is empty");
byte[] sessionKey = buildRedisSessionKey(session.getId());
int sessionTimeOut = PropertiesUtil.getInt("session.maxInactiveInterval", EXPIRE_TIME);
byte[] value = SerializeUtil.serialize(session);
RedisConnection redisConnection = getRedisConnection();
try {
redisConnection.set(sessionKey, value, Expiration.seconds(sessionTimeOut), SetOption.UPSERT);
} finally {
redisConnection.close();
}
}
示例5: getDataType
import org.springframework.data.redis.connection.RedisConnection; //導入方法依賴的package包/類
private String getDataType(String serverName, int dbIndex, String key) {
RedisTemplate redisTemplate = RedisApplication.redisTemplatesMap.get(serverName);
RedisConnection connection = RedisConnectionUtils.getConnection(redisTemplate.getConnectionFactory());
connection.select(dbIndex);
DataType dataType = connection.type(key.getBytes());
connection.close();
return dataType.name().toUpperCase();
}
示例6: getKV
import org.springframework.data.redis.connection.RedisConnection; //導入方法依賴的package包/類
private Object getKV(String serverName, int dbIndex, String key) {
RedisTemplate redisTemplate = RedisApplication.redisTemplatesMap.get(serverName);
RedisConnection connection = RedisConnectionUtils.getConnection(redisTemplate.getConnectionFactory());
connection.select(dbIndex);
DataType dataType = connection.type(key.getBytes());
connection.close();
Object values = null;
switch(dataType) {
case STRING:
values = redisDao.getSTRING(serverName, dbIndex, key);
break;
case LIST:
values = redisDao.getLIST(serverName, dbIndex, key);
break;
case SET:
values = redisDao.getSET(serverName, dbIndex, key);
break;
case ZSET:
values = redisDao.getZSET(serverName, dbIndex, key);
break;
case HASH:
values = redisDao.getHASH(serverName, dbIndex, key);
break;
case NONE:
//never be here
values = null;
}
return values;
}
示例7: initRedisKeysCache
import org.springframework.data.redis.connection.RedisConnection; //導入方法依賴的package包/類
protected void initRedisKeysCache(RedisTemplate redisTemplate, String serverName , int dbIndex) {
RedisConnection connection = RedisConnectionUtils.getConnection(redisTemplate.getConnectionFactory());
connection.select(dbIndex);
Set<byte[]> keysSet = connection.keys("*".getBytes());
connection.close();
List<RKey> tempList = new ArrayList<RKey>();
ConvertUtil.convertByteToString(connection, keysSet, tempList);
Collections.sort(tempList);
CopyOnWriteArrayList<RKey> redisKeysList = new CopyOnWriteArrayList<RKey>(tempList);
if(redisKeysList.size()>0) {
redisKeysListMap.put(serverName+DEFAULT_SEPARATOR+dbIndex, redisKeysList);
}
}