Skip to content

Command Comparison: Redisson → Glide

The SET command stores a key-value pair in Valkey, while GET retrieves the value associated with a key.

  • Redisson uses RBucket objects to represent string values.
  • Glide provides direct set() and get() methods on the client.

Redisson

// Set a key-value pair
RBucket<String> bucket = redisson.getBucket("key");
bucket.set("value");
// Retrieve the value
String value = bucket.get(); // value = "value"
// Alternative approach
redisson.getBucket("key").set("value");
String value = redisson.getBucket("key").get(); // value = "value"

Glide

// Set a key-value pair
client.set("key", "value");
// Retrieve the value
String value = client.get("key").get(); // value = "value"

Note: The .get() is required in Glide because get() returns a CompletableFuture<String>.

The SETEX command sets a key with an expiration time in seconds.

  • In Redisson, expiration is handled using expire() method or setAsync() with duration.
  • In Glide, expiration is handled using an additional parameter in the set() command.

Redisson

RBucket<String> bucket = redisson.getBucket("key");
bucket.set("value", Duration.ofSeconds(5)); // Set with 5 second expiry

Glide

client.set("key", "value", SetOptions.builder().expiry(Seconds(5L)).build()).get();

The SETNX command sets a key only if it does not already exist.

  • In Redisson, this is handled using trySet() method which returns true if the key was set.
  • In Glide, this is handled using conditional set options within the set() command.

Redisson

RBucket<String> bucket = redisson.getBucket("key");
boolean result = bucket.trySet("value"); // Returns true if key was set, false if key exists

Glide

import glide.api.models.commands.SetOptions;
import glide.api.models.commands.ConditionalChange;
String result = client.set("key", "value", SetOptions.builder()
.conditionalSet(ConditionalChange.ONLY_IF_DOES_NOT_EXIST)
.build()).get(); // Returns "OK" if key was set, null if key exists

The MSET command sets multiple key-value pairs in a single operation, while MGET retrieves values for multiple keys.

  • In Redisson, RBuckets is used for bulk operations with Maps.
  • In Glide, mset() accepts a Map and mget() requires an array of keys.

Redisson

// Multiple set
RBuckets buckets = redisson.getBuckets();
Map<String, String> map = new HashMap<>();
map.put("key1", "value1");
map.put("key2", "value2");
buckets.set(map);
// Multiple get
Map<String, String> values = buckets.get("key1", "key2"); // {key1=value1, key2=value2}

Glide

// Multiple set
Map<String, String> map = new HashMap<>();
map.put("key1", "value1");
map.put("key2", "value2");
client.mset(map);
// Multiple get
String[] values = client.mget(new String[]{"key1", "key2"}).get(); // ["value1", "value2"]

The INCR command increments the value of a key by 1, while DECR decrements it by 1.

  • Redisson uses RAtomicLong for atomic increment/decrement operations.
  • Glide provides direct incr() and decr() methods.

Redisson

redisson.getBucket("counter").set("1");
RAtomicLong counter = redisson.getAtomicLong("counter");
counter.incrementAndGet(); // counter = 2
counter.decrementAndGet(); // counter = 1

Glide

client.set("counter", "1");
client.incr("counter").get(); // counter = 2
client.decr("counter").get(); // counter = 1

The INCRBY command increases the value of a key by a specified amount, while DECRBY decreases it by a specified amount.

  • Redisson uses RAtomicLong with addAndGet() method.
  • Glide provides direct incrBy() and decrBy() methods.

Redisson

RAtomicLong counter = redisson.getAtomicLong("counter");
long result = counter.addAndGet(5); // counter: 5
result = counter.addAndGet(-2); // counter: 3

Glide

long counter = client.incrBy("counter", 5).get(); // counter: 5
counter = client.decrBy("counter", 2).get(); // counter: 3

The APPEND command appends a value to the end of an existing string stored at a key.

  • Redisson doesn’t have a direct append method; you need to get, concatenate, and set.
  • Glide provides a direct append() method.

Redisson

RBucket<String> bucket = redisson.getBucket("greeting");
bucket.set("Hello");
String current = bucket.get();
bucket.set(current + " World"); // Manual append
String result = bucket.get(); // "Hello World"

Glide

client.set("greeting", "Hello");
Long length = client.append("greeting", " World").get(); // Returns length: 11
String result = client.get("greeting").get(); // "Hello World"

The GETRANGE command retrieves a substring from a string value stored at a key, while SETRANGE overwrites part of a string at a key starting at a specified offset.

  • Redisson doesn’t have direct getrange/setrange methods.
  • Glide provides direct getRange() and setRange() methods.

Redisson

// Redisson doesn't have direct getrange/setrange support
// You would need to implement this manually using get/set operations
RBucket<String> bucket = redisson.getBucket("key");
bucket.set("Hello World");
String value = bucket.get();
String substring = value.substring(0, 5); // "Hello" (manual implementation)

Glide

client.set("key", "Hello World");
String result = client.getRange("key", 0, 4).get(); // "Hello"
client.setRange("key", 6, "Redis").get(); // Returns length: 11
String updated = client.get("key").get(); // "Hello Redis"

The DEL command removes one or more keys from Valkey.

  • In Redisson, individual objects have delete() methods, or use RKeys for bulk operations.
  • In Glide, del() requires an array of keys.

Redisson

// Delete single key
redisson.getBucket("key1").delete();
// Delete multiple keys
RKeys keys = redisson.getKeys();
long deleted = keys.delete("key1", "key2"); // 2 (number of keys deleted)

Glide

Long deleted = client.del(new String[]{"key1", "key2"}).get(); // 2 (number of keys deleted)

The EXISTS command checks if one or more keys exist in Valkey.

  • In Redisson, individual objects have isExists() methods, or use RKeys for bulk operations.
  • In Glide, exists() takes a list of keys and returns a Long indicating how many exist.

Redisson

// Check single key
boolean exists = redisson.getBucket("key").isExists(); // true or false
// Check multiple keys
RKeys keys = redisson.getKeys();
long count = keys.countExists("key1", "key2"); // number of keys that exist

Glide

Long count = client.exists(new String[]{"key1", "key2"}).get(); // number of keys that exist

The EXPIRE command sets a time-to-live (TTL) for a key, after which it will be automatically deleted. The TTL command returns the remaining time-to-live for a key.

  • In Redisson, objects implement RExpirable interface with expire() and remainTimeToLive() methods.
  • In Glide, expire() and ttl() are direct client methods.

Redisson

RBucket<String> bucket = redisson.getBucket("key");
bucket.set("value");
boolean success = bucket.expire(Duration.ofSeconds(10)); // true (success)
long ttl = bucket.remainTimeToLive(); // milliseconds remaining

Glide

Long success = client.expire("key", 10).get(); // 1 (success)
Long ttl = client.ttl("key").get(); // 10 (seconds remaining)

The KEYS command returns all keys matching a pattern, while SCAN iterates through keys in a more efficient way for production use.

  • Redisson provides RKeys interface with getKeys() and getKeysStream() methods.
  • Glide provides direct keys() and scan() methods.

Redisson

RKeys keys = redisson.getKeys();
// KEYS (not recommended for production)
Iterable<String> allKeys = keys.getKeysByPattern("*");
// SCAN (recommended for production)
Iterable<String> keysIterable = keys.getKeysStream().toIterable();
for (String key : keysIterable) {
System.out.println("Key: " + key);
}

Glide

// KEYS (not recommended for production)
String[] allKeys = client.keys("*").get();
// SCAN (recommended for production)
String cursor = "0";
Object[] result;
do {
result = client.scan(cursor).get();
cursor = result[0].toString();
Object[] keys = (Object[]) result[1];
if (keys.length > 0) {
String keyList = Arrays.stream(keys)
.map(obj -> (String) obj)
.collect(Collectors.joining(", "));
System.out.println("SCAN iteration: " + keyList);
}
} while (!cursor.equals("0"));

The RENAME command renames a key, while RENAMENX renames a key only if the new key does not already exist.

  • In Redisson, objects have rename() and renamenx() methods.
  • In Glide, rename() and renameNx() are direct client methods.

Redisson

RBucket<String> bucket = redisson.getBucket("oldkey");
bucket.set("value");
bucket.rename("newkey"); // void
RBucket<String> bucket1 = redisson.getBucket("key1");
bucket1.set("value1");
boolean success = bucket1.renamenx("key2"); // true (success)

Glide

client.set("oldkey", "value");
String result = client.rename("oldkey", "newkey").get(); // "OK"
client.set("key1", "value1");
Long success = client.renameNx("key1", "key2").get(); // 1 (success)

The HSET command sets field-value pairs in a hash stored at a key, while HGET retrieves the value of a specific field.

  • In Redisson, RMap is used for hash operations with put() and get() methods.
  • In Glide, hset() accepts a Map and hget() retrieves individual fields.

Redisson

RMap<String, String> map = redisson.getMap("hash");
// Set a single field
map.put("key1", "1"); // returns previous value or null
// Set multiple fields
Map<String, String> fields = new HashMap<>();
fields.put("key1", "1");
fields.put("key2", "2");
map.putAll(fields);
// Get a single field
String value = map.get("key1"); // "1"

Glide

// Set a single field
Map<String, String> singleField = new HashMap<>();
singleField.put("key1", "1");
client.hset("hash", singleField).get(); // 1 (field added)
// Set multiple fields
Map<String, String> map = new HashMap<>();
map.put("key1", "1");
map.put("key2", "2");
client.hset("hash", map).get(); // 2 (fields added)
// Get a single field
String value = client.hget("hash", "key1").get(); // "1"

The HMSET command sets multiple field-value pairs in a hash, while HMGET retrieves values for multiple fields.

  • In Redisson, RMap.putAll() is used for setting multiple fields, and getAll() for getting multiple fields.
  • In Glide, hset() is used for setting multiple fields, and hmget() requires an array of fields.

Redisson

RMap<String, String> map = redisson.getMap("hash");
// Set multiple fields
Map<String, String> fields = new HashMap<>();
fields.put("key1", "1");
fields.put("key2", "2");
map.putAll(fields);
// Get multiple fields
Map<String, String> values = map.getAll(Set.of("key1", "key2")); // {key1=1, key2=2}

Glide

// Set multiple fields (same as hset in Glide)
Map<String, String> map = new HashMap<>();
map.put("key1", "1");
map.put("key2", "2");
client.hset("hash", map).get(); // 2 (fields added)
// Get multiple fields
String[] values = client.hmget("hash", new String[]{"key1", "key2"}).get(); // ["1", "2"]

The HGETALL command retrieves all field-value pairs from a hash.

  • Redisson uses RMap.readAllMap() to get all entries.
  • Glide provides direct hgetall() method.

Redisson

RMap<String, String> map = redisson.getMap("user");
Map<String, String> fields = new HashMap<>();
fields.put("name", "John");
fields.put("age", "30");
map.putAll(fields);
Map<String, String> user = map.readAllMap(); // {name=John, age=30}

Glide

Map<String, String> map = new HashMap<>();
map.put("name", "John");
map.put("age", "30");
client.hset("user", map);
Map<String, String> user = client.hgetall("user").get(); // {name=John, age=30}

The HDEL command removes one or more fields from a hash, while HEXISTS checks if a field exists in a hash.

  • In Redisson, RMap provides remove() and containsKey() methods.
  • In Glide, hdel() requires an array of fields, and hexists() returns 1 or 0.

Redisson

RMap<String, String> map = redisson.getMap("hash");
Map<String, String> fields = new HashMap<>();
fields.put("key1", "1");
fields.put("key2", "2");
fields.put("key3", "3");
map.putAll(fields);
// Remove fields
map.remove("key1");
map.remove("key2");
// Check existence
boolean exists = map.containsKey("key3"); // true (exists)
boolean notExists = map.containsKey("key1"); // false (doesn't exist)

Glide

Map<String, String> map = new HashMap<>();
map.put("key1", "1");
map.put("key2", "2");
map.put("key3", "3");
client.hset("hash", map);
Long deleted = client.hdel("hash", new String[]{"key1", "key2"}).get(); // 2 (fields deleted)
Long exists = client.hexists("hash", "key3").get(); // 1 (exists)
Long notExists = client.hexists("hash", "key1").get(); // 0 (doesn't exist)

The LPUSH command adds elements to the beginning of a list, while RPUSH adds elements to the end of a list.

  • In Redisson, RList provides addFirst() and add() methods.
  • In Glide, lpush() and rpush() require arrays of elements.

Redisson

RList<String> list = redisson.getList("list");
list.addFirst("c");
list.addFirst("b");
list.addFirst("a"); // List: [a, b, c]
list.add("d");
list.add("e"); // List: [a, b, c, d, e]

Glide

Long lengthOfList = client.lpush("list", new String[]{"a", "b", "c"}).get(); // lengthOfList = 3
lengthOfList = client.rpush("list", new String[]{"d", "e"}).get(); // lengthOfList = 5

The LPOP command removes and returns the first element of a list, while RPOP removes and returns the last element.

  • In Redisson, RList provides removeFirst() and removeLast() methods.
  • Glide provides direct lpop() and rpop() methods.

Redisson

RList<String> list = redisson.getList("list");
list.add("a");
list.add("b");
list.add("c");
String first = list.removeFirst(); // "a"
String last = list.removeLast(); // "c"

Glide

client.rpush("list", new String[]{"a", "b", "c"});
String first = client.lpop("list").get(); // "a"
String last = client.rpop("list").get(); // "c"

The LRANGE command retrieves a range of elements from a list.

  • In Redisson, RList provides range() method.
  • Glide provides direct lrange() method.

Redisson

RList<String> list = redisson.getList("list");
list.add("a");
list.add("b");
list.add("c");
list.add("d");
list.add("e");
List<String> elements = list.range(0, 2); // [a, b, c]

Glide

client.rpush("list", new String[]{"a", "b", "c", "d", "e"});
String[] elements = client.lrange("list", 0, 2).get(); // ["a", "b", "c"]

The SADD command adds one or more members to a set, while SMEMBERS returns all members of a set.

  • In Redisson, RSet provides add() and readAll() methods.
  • In Glide, sadd() requires an array of members.

Redisson

RSet<String> set = redisson.getSet("set");
boolean added1 = set.add("a"); // true
boolean added2 = set.add("b"); // true
boolean added3 = set.add("c"); // true
Set<String> members = set.readAll(); // [a, b, c]

Glide

Long added = client.sadd("set", new String[]{"a", "b", "c"}).get(); // 3 (members added)
String[] members = client.smembers("set").get(); // ["a", "b", "c"]

The SREM command removes one or more members from a set, while SISMEMBER checks if a value is a member of a set.

  • In Redisson, RSet provides remove() and contains() methods.
  • In Glide, srem() requires an array of members, and sismember() returns 1 or 0.

Redisson

RSet<String> set = redisson.getSet("set");
set.add("a");
set.add("b");
set.add("c");
boolean removed1 = set.remove("a"); // true
boolean removed2 = set.remove("b"); // true
boolean isMember = set.contains("c"); // true (is member)
boolean notMember = set.contains("a"); // false (not member)

Glide

client.sadd("set", new String[]{"a", "b", "c"});
Long removed = client.srem("set", new String[]{"a", "b"}).get(); // 2 (members removed)
Long isMember = client.sismember("set", "c").get(); // 1 (is member)
Long notMember = client.sismember("set", "a").get(); // 0 (not member)

The ZADD command adds one or more members with scores to a sorted set, while ZRANGE retrieves members from a sorted set by index range.

  • In Redisson, RScoredSortedSet provides add() and valueRange() methods.
  • In Glide, zadd() requires an array of score-member pairs.

Redisson

RScoredSortedSet<String> sortedSet = redisson.getScoredSortedSet("sortedSet");
// Add members with scores
sortedSet.add(1.0, "one");
sortedSet.add(2.0, "two");
sortedSet.add(3.0, "three");
// Get range of members
Collection<String> members = sortedSet.valueRange(0, -1); // [one, two, three]
// With scores
Collection<ScoredEntry<String>> withScores = sortedSet.entryRange(0, -1);
// [{one=1.0}, {two=2.0}, {three=3.0}]

Glide

// Add members with scores
Object[] scoreMembers = new Object[] {
new Object[] { 1.0, "one" },
new Object[] { 2.0, "two" },
new Object[] { 3.0, "three" }
};
Long added = client.zadd("sortedSet", scoreMembers).get(); // 3 (members added)
// Get range of members
String[] members = client.zrange("sortedSet", 0, -1).get(); // ["one", "two", "three"]
// With scores
Object[] withScores = client.zrange("sortedSet", 0, -1, "WITHSCORES").get();
// ["one", "1", "two", "2", "three", "3"]

The ZREM command removes one or more members from a sorted set, while ZSCORE returns the score of a member in a sorted set.

  • In Redisson, RScoredSortedSet provides remove() and getScore() methods.
  • In Glide, zrem() requires an array of members.

Redisson

RScoredSortedSet<String> sortedSet = redisson.getScoredSortedSet("sortedSet");
sortedSet.add(1.0, "one");
sortedSet.add(2.0, "two");
sortedSet.add(3.0, "three");
boolean removed1 = sortedSet.remove("one"); // true
boolean removed2 = sortedSet.remove("two"); // true
Double score = sortedSet.getScore("three"); // 3.0

Glide

Object[] scoreMembers = new Object[] {
new Object[] { 1.0, "one" },
new Object[] { 2.0, "two" },
new Object[] { 3.0, "three" }
};
client.zadd("sortedSet", scoreMembers);
Long removed = client.zrem("sortedSet", new String[]{"one", "two"}).get(); // 2 (members removed)
String score = client.zscore("sortedSet", "three").get(); // "3"

The ZRANK command returns the rank (position) of a member in a sorted set, while ZREVRANK returns the rank in reverse order.

  • In Redisson, RScoredSortedSet provides rank() and revRank() methods.
  • Glide provides direct zrank() and zrevrank() methods.

Redisson

RScoredSortedSet<String> sortedSet = redisson.getScoredSortedSet("sortedSet");
sortedSet.add(1.0, "one");
sortedSet.add(2.0, "two");
sortedSet.add(3.0, "three");
Integer rank = sortedSet.rank("two"); // 1 (0-based index)
Integer revRank = sortedSet.revRank("two"); // 1 (0-based index from end)

Glide

Object[] scoreMembers = new Object[] {
new Object[] { 1.0, "one" },
new Object[] { 2.0, "two" },
new Object[] { 3.0, "three" }
};
client.zadd("sortedSet", scoreMembers);
Long rank = client.zrank("sortedSet", "two").get(); // 1 (0-based index)
Long revRank = client.zrevrank("sortedSet", "two").get(); // 1 (0-based index from end)

The MULTI command starts a transaction block, while EXEC executes all commands issued after MULTI.

  • In Redisson, transactions are handled using RBatch for batching operations.
  • In Glide, transactions are represented as a Transaction object.

Redisson

// Create a batch (similar to transaction)
RBatch batch = redisson.createBatch();
// Add commands to the batch
batch.getBucket("key").setAsync("value");
batch.getAtomicLong("counter").incrementAndGetAsync();
batch.getBucket("key").getAsync();
// Execute the batch
BatchResult<?> result = batch.execute();
List<?> responses = result.getResponses();
System.out.println(responses); // [void, 1, value]

Glide

import glide.api.models.Transaction;
// Initialize a transaction object
Transaction transaction = new Transaction();
// Add commands to the transaction
transaction.set("key", "value");
transaction.incr("counter");
transaction.get("key");
// Execute the transaction
Object[] result = client.exec(transaction).get();
System.out.println(Arrays.toString(result)); // [OK, 1, value]

The EVAL command executes a Lua script on the server, while EVALSHA executes a script cached on the server using its SHA1 hash.

  • In Redisson, scripts are executed using RScript interface.
  • In Glide, scripts are created using the Script class and executed with invokeScript().

Redisson

RScript script = redisson.getScript();
// EVAL
String luaScript = "return 'Hello, Lua!'";
Object result = script.eval(RScript.Mode.READ_ONLY, luaScript, RScript.ReturnType.VALUE);
System.out.println(result); // Hello, Lua!
// With keys and arguments
String scriptWithArgs = "return {KEYS[1], ARGV[1]}";
List<Object> resultWithArgs = script.eval(RScript.Mode.READ_ONLY, scriptWithArgs,
RScript.ReturnType.MULTI, Arrays.asList("key"), "value");
System.out.println(resultWithArgs); // [key, value]
// EVALSHA
String sha1 = script.scriptLoad(scriptWithArgs);
List<Object> shaResult = script.evalSha(RScript.Mode.READ_ONLY, sha1,
RScript.ReturnType.MULTI, Arrays.asList("key"), "value");
System.out.println(shaResult); // [key, value]

Glide

import glide.api.models.Script;
import glide.api.models.ScriptOptions;
// EVAL
String script = "return 'Hello, Lua!'";
Script luaScript = new Script(script, false);
String result = (String) client.invokeScript(luaScript).get();
System.out.println(result); // Hello, Lua!
// With keys and arguments
String scriptWithArgs = "return {KEYS[1], ARGV[1]}";
Script luaScriptWithArgs = new Script(scriptWithArgs, false);
ScriptOptions options = ScriptOptions.builder()
.key("key")
.arg("value")
.build();
Object[] resultWithArgs = (Object[]) client.invokeScript(luaScriptWithArgs, options).get();
System.out.println(Arrays.toString(resultWithArgs)); // [key, value]

The AUTH command authenticates a client connection to the Valkey server.

  • In Redisson, authentication is handled in the configuration during client creation.
  • In Glide, authentication can be updated using updateConnectionPassword().

Redisson

// Authentication is handled during configuration
Config config = new Config();
config.useSingleServer()
.setAddress("redis://localhost:6379")
.setPassword("mypass");
RedissonClient redisson = Redisson.create(config);

Glide

String result = client.updateConnectionPassword("mypass", true).get(); // OK

Both Redisson and Glide provide ways to execute custom commands.

  • In Redisson, you can execute raw commands using the low-level command executor.
  • In Glide, you can execute raw commands using customCommand().

Redisson

// Redisson doesn't have a direct way to execute arbitrary commands
// You would typically use the appropriate high-level API methods
// For truly custom commands, you'd need to access the underlying connection

Glide

// Execute a raw command
String rawResult = client.customCommand(new String[]{"SET", "key", "value"}).get();
System.out.println(rawResult); // OK

Properly closing connections is important to free up resources and avoid connection leaks.

  • In Redisson, you need to call shutdown() to properly close all connections and resources.
  • In Glide, you only need to call close() on the client.

Redisson

// Shutdown Redisson client (closes all connections and resources)
redisson.shutdown();
// For graceful shutdown with timeout
redisson.shutdown(10, 30, TimeUnit.SECONDS);

Glide

// Close client (works for both standalone and cluster)
client.close();