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


Java RedisConnection.close方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:15,代碼來源:RedisSessionDAO.java

示例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();
            }
        }
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:14,代碼來源:RedisSessionDAO.java

示例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;
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:14,代碼來源:RedisSessionDAO.java

示例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();
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:13,代碼來源:RedisSessionDAO.java

示例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();
}
 
開發者ID:mauersu,項目名稱:redis-admin,代碼行數:9,代碼來源:RedisServiceImpl.java

示例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;
}
 
開發者ID:mauersu,項目名稱:redis-admin,代碼行數:30,代碼來源:RedisServiceImpl.java

示例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);
	}
}
 
開發者ID:mauersu,項目名稱:redis-admin,代碼行數:14,代碼來源:RedisApplication.java


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