private RedisSession loadFromStore(final String clusterId, final RedisSession current) { List<String> redisData = jedisExecutor.execute( new JedisCallback<List<String>>() { @Override public List<String> execute(Jedis jedis) { final String key = RedisSessionIdManager.REDIS_SESSION_KEY + clusterId; if (current == null) { return jedis.exists(key) ? jedis.hmget(key, FIELDS) : null; } else { String val = jedis.hget(key, "lastSaved"); if (val == null) { // no session in store return Collections.emptyList(); } if (current.lastSaved != Long.parseLong(val)) { // session has changed - reload return jedis.hmget(key, FIELDS); } else { // session dit not changed in cache since last save return null; } } } }); if (redisData == null) { // case where session has not been modified return current; } if (redisData.isEmpty() || redisData.get(0) == null) { // no session found in redis (no data) return null; } Map<String, String> data = new HashMap<String, String>(); for (int i = 0; i < FIELDS.length; i++) data.put(FIELDS[i], redisData.get(i)); String attrs = data.get("attributes"); //noinspection unchecked return new RedisSession( data, attrs == null ? new HashMap<String, Object>() : serializer.deserialize(attrs, Map.class)); }