/** * Gets the value given the key. Note that it does NOT work with hash values or list values * * @param key * @return value of the key. */ @Override public Object get(Object key) { if (isInTransaction()) { throw new RuntimeException("Cannot call get when in redis transaction"); } return connection.get(key.toString()); }
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(); }