Below is a comprehensive chart comparing common Redis commands between redis-py and Valkey GLIDE:
| Command | redis-py | Valkey GLIDE |
|---|
| Connect | redis.Redis(host='localhost', port=6379) | GlideClient.create(GlideClientConfiguration(addresses=[NodeAddress(host="localhost", port=6379)])) |
| Cluster | RedisCluster(startup_nodes=[{"host": "127.0.0.1", "port": 6379}]) | GlideClusterClient.create(GlideClusterClientConfiguration(addresses=[NodeAddress(host="127.0.0.1", port=6379)])) |
| Auth | r.auth('pass') | Set in configuration with ServerCredentials |
| Select DB | r.select(1) | client.select(1) |
| Command | redis-py | Valkey GLIDE |
|---|
| SET | r.set('key', 'val') | client.set('key', 'val') |
| GET | r.get('key') | client.get('key') |
| SETEX | r.setex('key', 10, 'val') | client.set('key', 'val', expiry=ExpirySet(ExpiryType.SEC, 10)) |
| SETNX | r.setnx('key', 'val') | client.set('key', 'val', conditional_set=ConditionalChange.ONLY_IF_DOES_NOT_EXIST) |
| MSET | r.mset({'key1': 'val1'}) | client.mset({'key1': 'val1'}) |
| MGET | r.mget(['key1', 'key2']) | client.mget(['key1', 'key2']) |
| INCR | r.incr('counter') | client.incr('counter') |
| DECR | r.decr('counter') | client.decr('counter') |
| INCRBY | r.incrby('counter', 5) | client.incrby('counter', 5) |
| DECRBY | r.decrby('counter', 5) | client.decrby('counter', 5) |
| APPEND | r.append('key', 'val') | client.append('key', 'val') |
| GETRANGE | r.getrange('key', 0, 3) | client.getrange('key', 0, 3) |
| SETRANGE | r.setrange('key', 0, 'val') | client.setrange('key', 0, 'val') |
| Command | redis-py | Valkey GLIDE |
|---|
| DEL | r.delete('key1', 'key2') or r.delete(['key1', 'key2']) | client.delete(['key1', 'key2']) |
| EXISTS | r.exists('key1', 'key2') or r.exists(['key1', 'key2']) | client.exists(['key1', 'key2']) |
| EXPIRE | r.expire('key', 10) | client.expire('key', 10) |
| TTL | r.ttl('key') | client.ttl('key') |
| KEYS | r.keys('pattern') | client.keys('pattern') |
| SCAN | r.scan(cursor=0, match='*') | client.scan('0') |
| RENAME | r.rename('old', 'new') | client.rename('old', 'new') |
| RENAMENX | r.renamenx('old', 'new') | client.renamenx('old', 'new') |
| Command | redis-py | Valkey GLIDE |
|---|
| HSET | r.hset('hash', 'k1', 'v1') or r.hset('hash', mapping={'k1': 'v1'}) | client.hset('hash', {'k1': 'v1'}) |
| HGET | r.hget('hash', 'field') | client.hget('hash', 'field') |
| HMSET | r.hmset('hash', {'k1': 'v1'}) | client.hset('hash', {'k1': 'v1'}) |
| HMGET | r.hmget('hash', ['k1', 'k2']) | client.hmget('hash', ['k1', 'k2']) |
| HGETALL | r.hgetall('hash') | client.hgetall('hash') |
| HDEL | r.hdel('hash', 'k1', 'k2') or r.hdel('hash', ['k1', 'k2']) | client.hdel('hash', ['k1', 'k2']) |
| HEXISTS | r.hexists('hash', 'field') | client.hexists('hash', 'field') |
| Command | redis-py | Valkey GLIDE |
|---|
| LPUSH | r.lpush('list', 'a', 'b') or r.lpush('list', ['a', 'b']) | client.lpush('list', ['a', 'b']) |
| RPUSH | r.rpush('list', 'a', 'b') or r.rpush('list', ['a', 'b']) | client.rpush('list', ['a', 'b']) |
| LPOP | r.lpop('list') | client.lpop('list') |
| RPOP | r.rpop('list') | client.rpop('list') |
| LRANGE | r.lrange('list', 0, -1) | client.lrange('list', 0, -1) |
| Command | redis-py | Valkey GLIDE |
|---|
| SADD | r.sadd('set', 'a', 'b') or r.sadd('set', ['a', 'b']) | client.sadd('set', ['a', 'b']) |
| SMEMBERS | r.smembers('set') | client.smembers('set') |
| SREM | r.srem('set', 'a', 'b') or r.srem('set', ['a', 'b']) | client.srem('set', ['a', 'b']) |
| SISMEMBER | r.sismember('set', 'a') | client.sismember('set', 'a') |
| Command | redis-py | Valkey GLIDE |
|---|
| ZADD | r.zadd('zset', {'a': 1, 'b': 2}) | client.zadd('zset', [{'score': 1, 'member': 'a'}, {'score': 2, 'member': 'b'}]) |
| ZRANGE | r.zrange('zset', 0, -1) | client.zrange('zset', 0, -1) |
| ZRANGE with scores | r.zrange('zset', 0, -1, withscores=True) | client.zrange('zset', 0, -1, with_scores=True) |
| ZREM | r.zrem('zset', 'a', 'b') or r.zrem('zset', ['a', 'b']) | client.zrem('zset', ['a', 'b']) |
| ZSCORE | r.zscore('zset', 'a') | client.zscore('zset', 'a') |
| ZRANK | r.zrank('zset', 'a') | client.zrank('zset', 'a') |
| ZREVRANK | r.zrevrank('zset', 'a') | client.zrevrank('zset', 'a') |
v| Command | redis-py | Valkey GLIDE |
|---------|---------|--------------|
| MULTI/EXEC | r.pipeline(transaction=True).set('k', 'v').get('k').execute() | client.exec(Transaction().set('k', 'v').get('k')) |
| Command | redis-py | Valkey GLIDE |
|---|
| EVAL | r.eval(script, 1, 'key', 'arg') | client.invoke_script(Script(script), keys=['key'], args=['arg']) |
| EVALSHA | r.evalsha(sha, 1, 'key', 'arg') | client.invoke_script(Script(script), keys=['key'], args=['arg']) |
| Command | redis-py | Valkey GLIDE |
|---|
| Raw Command | r.execute_command('SET', 'key', 'value') | client.custom_command(['SET', 'key', 'value']) |
| Command | redis-py | Valkey GLIDE |
|---|
| Close | r.close() | client.close() |