@SuppressWarnings({"unchecked", "rawtypes"}) @Override public void put(Object key, Object value) { if (value instanceof Map) { connection.hmset(key.toString(), (Map) value); } else { connection.set(key.toString(), value.toString()); } if (keyExpiryTime != -1) { connection.expire(key.toString(), keyExpiryTime); } }
public static void main(String[] args) { // Syntax: redis://[password@]host[:port][/databaseNumber] RedisClient redisClient = new RedisClient(RedisURI.create("redis://password@localhost:6379/0")); RedisConnection<String, String> connection = redisClient.connect(); System.out.println("Connected to Redis"); connection.set("foo", "bar"); String value = connection.get("foo"); System.out.println(value); connection.close(); redisClient.shutdown(); }