{ Logger logger LoggerFactory.getLogger(JedisUtils.); JedisUtils() { } JedisSlotBasedConnectionHandler jedisSlotBasedConnectionHandler SpringUtils.getBean(JedisSlotBasedConnectionHandler.); get( key) { value ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(key)) { value jedis.get(key); value StringUtils.isNotBlank(value) .equalsIgnoreCase(value) value : ; } } (JedisHandleException e) { LoggerUtils.logError(logger, key e.getMessage()); } { releaseConnection(jedis); } value; } set( key, value, cacheSeconds) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.set(key, value); (cacheSeconds ) { jedis.expire(key, cacheSeconds); } } (JedisDataException e) { LoggerUtils.logError(logger, e.getMessage()); } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } getObject( key) { value ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(ObjectUtils.getBytes(key))) { value ObjectUtils.toObject(jedis.get(ObjectUtils.getBytes(key))); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } value; } setObject( key, value, cacheSeconds) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.set(ObjectUtils.getBytes(key), ObjectUtils.toBytes(value)); (cacheSeconds ) { jedis.expire(key, cacheSeconds); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } List getListString( key) { List value ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(key)) { value jedis.lrange(key, , ); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } value; } List getObjectList( key) { List value ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(ObjectUtils.getBytes(key))) { List[] list jedis.lrange(ObjectUtils.getBytes(key), , ); value Lists.newArrayList(); ([] bs : list) { value.add(ObjectUtils.toObject(bs)); } } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } value; } setList( key, List value, cacheSeconds) { result ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(key)) { jedis.del(key); } result jedis.rpush(key, ([]) value.toArray()); (cacheSeconds ) { jedis.expire(key, cacheSeconds); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } setObjectList( key, List value, cacheSeconds) { result ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(ObjectUtils.getBytes(key))) { jedis.del(key); } List[] list Lists.newArrayList(); ( o : value) { list.add(ObjectUtils.toBytes(o)); } result jedis.rpush(ObjectUtils.getBytes(key), ([][]) list.toArray()); (cacheSeconds ) { jedis.expire(key, cacheSeconds); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } listAdd( key, ... value) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.rpush(key, value); } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } listObjectAdd( key, ... value) { result ; Jedis jedis ; { jedis getConnection(key); List[] list Lists.newArrayList(); ( o : value) { list.add(ObjectUtils.toBytes(o)); } result jedis.rpush(ObjectUtils.getBytes(key), ([][]) list.toArray()); } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } Set getSet( key) { Set value ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(key)) { value jedis.smembers(key); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } value; } Set getObjectSet( key) { Set value ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(ObjectUtils.getBytes(key))) { value Sets.newHashSet(); Set[] set jedis.smembers(ObjectUtils.getBytes(key)); ([] bs : set) { value.add(ObjectUtils.toObject(bs)); } } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } value; } setSet( key, Set value, cacheSeconds) { result ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(key)) { jedis.del(key); } result jedis.sadd(key, ([]) value.toArray()); (cacheSeconds ) { jedis.expire(key, cacheSeconds); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } setObjectSet( key, Set value, cacheSeconds) { result ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(ObjectUtils.getBytes(key))) { jedis.del(key); } Set[] set Sets.newHashSet(); ( o : value) { set.add(ObjectUtils.toBytes(o)); } result jedis.sadd(ObjectUtils.getBytes(key), ([][]) set.toArray()); (cacheSeconds ) { jedis.expire(key, cacheSeconds); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } setSetAdd( key, ... value) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.sadd(key, value); } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } setSetObjectAdd( key, ... value) { result ; Jedis jedis ; { jedis getConnection(key); Set[] set Sets.newHashSet(); ( o : value) { set.add(ObjectUtils.toBytes(o)); } result jedis.rpush(ObjectUtils.getBytes(key), ([][]) set.toArray()); } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } Map, getMap( key) { Map, value ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(key)) { value jedis.hgetAll(key); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } value; } Map, getObjectMap( key) { Map, value ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(ObjectUtils.getBytes(key))) { value Maps.newHashMap(); Map[], [] map jedis.hgetAll(ObjectUtils.getBytes(key)); (Map.Entry[], [] e : map.entrySet()) { value.put( (e.getKey(), Charset.forName(CharsetConst.CHARSET_UT)), ObjectUtils.toObject(e.getValue())); } } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } value; } setMap( key, Map, value, cacheSeconds) { result ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(key)) { jedis.del(key); } result jedis.hmset(key, value); (cacheSeconds ) { jedis.expire(key, cacheSeconds); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } setObjectMap( key, Map, value, cacheSeconds) { result ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(ObjectUtils.getBytes(key))) { jedis.del(key); } Map[], [] map Maps.newHashMap(); (Map.Entry, e : value.entrySet()) { map.put(ObjectUtils.getBytes(e.getKey()), ObjectUtils.toBytes(e.getValue())); } result jedis.hmset(ObjectUtils.getBytes(key), (Map[], []) map); (cacheSeconds ) { jedis.expire(key, cacheSeconds); } } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } mapPut( key, Map, value) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.hmset(key, value); } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } mapObjectPut( key, Map, value) { result ; Jedis jedis ; { jedis getConnection(key); Map[], [] map Maps.newHashMap(); (Map.Entry, e : value.entrySet()) { map.put(ObjectUtils.getBytes(e.getKey()), ObjectUtils.toBytes(e.getValue())); } result jedis.hmset(ObjectUtils.getBytes(key), (Map[], []) map); logger.debug(, key, value); } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } { releaseConnection(jedis); } result; } mapRemove( key, mapKey) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.hdel(key, mapKey); logger.debug(, key, mapKey); } (JedisHandleException e) { LoggerUtils.logError(logger, key mapKey e.getMessage()); } { releaseConnection(jedis); } result; } mapObjectRemove( key, mapKey) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.hdel(ObjectUtils.getBytes(key), ObjectUtils.getBytes(mapKey)); } (JedisHandleException e) { LoggerUtils.logError(logger, key mapKey e.getMessage()); } { releaseConnection(jedis); } result; } mapExists( key, mapKey) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.hexists(key, mapKey); } (JedisHandleException e) { LoggerUtils.logError(logger, key mapKey e.getMessage()); } { releaseConnection(jedis); } result; } mapObjectExists( key, mapKey) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.hexists(ObjectUtils.getBytes(key), ObjectUtils.getBytes(mapKey)); } (JedisHandleException e) { LoggerUtils.logError(logger, key mapKey e.getMessage()); } { releaseConnection(jedis); } result; } del( key) { result ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(key)) { result jedis.del(key); } { logger.debug(, key); } } (JedisHandleException e) { LoggerUtils.logError(logger, key e.getMessage()); } { releaseConnection(jedis); } result; } delObject( key) { result ; Jedis jedis ; { jedis getConnection(key); (jedis.exists(ObjectUtils.getBytes(key))) { result jedis.del(ObjectUtils.getBytes(key)); logger.debug(, key); } { logger.debug(, key); } } (JedisHandleException e) { LoggerUtils.logError(logger, key e.getMessage()); } { releaseConnection(jedis); } result; } exists( key) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.exists(key); logger.debug(, key); } (JedisHandleException e) { LoggerUtils.logError(logger, key e.getMessage()); } { releaseConnection(jedis); } result; } existsObject( key) { result ; Jedis jedis ; { jedis getConnection(key); result jedis.exists(ObjectUtils.getBytes(key)); logger.debug(, key); } (JedisHandleException e) { LoggerUtils.logError(logger, key e.getMessage()); } { releaseConnection(jedis); } result; } Jedis getConnection( key) { Jedis jedis ; { jedis jedisSlotBasedConnectionHandler.getConnectionFromSlot(JedisClusterCRC16.getSlot(key)); } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } jedis; } releaseConnection(Jedis jedis) { { jedisSlotBasedConnectionHandler.returnConnection(jedis); } (JedisHandleException e) { LoggerUtils.logError(logger, e.getMessage()); } } }