Last active
January 18, 2022 20:22
-
-
Save gkorland/69c16eae7874f1045c616a1682759e95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### GETEX | |
import redis | |
r = redis.Redis() | |
r.set(“somekey”, “hello”) | |
r.getex(“somekey”, ex=15) | |
### >>> returns “Hello” | |
r.ttl(“somekey”) | |
### >>> 15 | |
#### CLIENT INFO AND KILL | |
import redis | |
r = redis.Redis() | |
r2 = redis.Redis() | |
r.client_setname('redis-py-c1') | |
r2.client_setname('redis-py-c2') | |
clients = [client for client in r.client_list() | |
if client.get('name') in ['redis-py-c1', 'redis-py-c2']] | |
clients_by_name = dict([(client.get('name'), client) | |
for client in clients]) | |
r.client_kill_filter(laddr=clients_by_name['redis-py-c2'].get('laddr')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment