How to remove all elements in Redis [duplicate]
This question already has an answer here:
How do I to flush redis db from python redis?
2 answers
How to remove all elements in Redis? I tried with the following snippet code from this post but didn't work.
I've such this:
import redis
from pprint import pprint
cli = redis.Redis('localhost')
dict_ = { # dummy
'tags': {'module': 'voltage', 'station': 'SNMP'},
'metric_name': 'voltage',
'value': 222,
'time': '2018-11-13T15:25:09'
}
cli.hmset("pythonDict", dict_)
for key in cli.keys('prefix:*'): # Didn't work.
cli.delete(key)
pprint(cli.hgetall("pythonDict"))
Still, the previous data appeared from dict_.
python redis
marked as duplicate by Community♦ Nov 13 '18 at 14:16
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How do I to flush redis db from python redis?
2 answers
How to remove all elements in Redis? I tried with the following snippet code from this post but didn't work.
I've such this:
import redis
from pprint import pprint
cli = redis.Redis('localhost')
dict_ = { # dummy
'tags': {'module': 'voltage', 'station': 'SNMP'},
'metric_name': 'voltage',
'value': 222,
'time': '2018-11-13T15:25:09'
}
cli.hmset("pythonDict", dict_)
for key in cli.keys('prefix:*'): # Didn't work.
cli.delete(key)
pprint(cli.hgetall("pythonDict"))
Still, the previous data appeared from dict_.
python redis
marked as duplicate by Community♦ Nov 13 '18 at 14:16
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How do I to flush redis db from python redis?
2 answers
How to remove all elements in Redis? I tried with the following snippet code from this post but didn't work.
I've such this:
import redis
from pprint import pprint
cli = redis.Redis('localhost')
dict_ = { # dummy
'tags': {'module': 'voltage', 'station': 'SNMP'},
'metric_name': 'voltage',
'value': 222,
'time': '2018-11-13T15:25:09'
}
cli.hmset("pythonDict", dict_)
for key in cli.keys('prefix:*'): # Didn't work.
cli.delete(key)
pprint(cli.hgetall("pythonDict"))
Still, the previous data appeared from dict_.
python redis
This question already has an answer here:
How do I to flush redis db from python redis?
2 answers
How to remove all elements in Redis? I tried with the following snippet code from this post but didn't work.
I've such this:
import redis
from pprint import pprint
cli = redis.Redis('localhost')
dict_ = { # dummy
'tags': {'module': 'voltage', 'station': 'SNMP'},
'metric_name': 'voltage',
'value': 222,
'time': '2018-11-13T15:25:09'
}
cli.hmset("pythonDict", dict_)
for key in cli.keys('prefix:*'): # Didn't work.
cli.delete(key)
pprint(cli.hgetall("pythonDict"))
Still, the previous data appeared from dict_.
This question already has an answer here:
How do I to flush redis db from python redis?
2 answers
python redis
python redis
asked Nov 13 '18 at 14:07
Benyamin JafariBenyamin Jafari
2,94632139
2,94632139
marked as duplicate by Community♦ Nov 13 '18 at 14:16
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Community♦ Nov 13 '18 at 14:16
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You're storing in Redis an object (dict_) under the key called 'pythonDict'. Just call cli.delete("pythonDict") to delete it.
Thanks a lot. It works.
– Benyamin Jafari
Nov 13 '18 at 14:15
What is the difference between this line andcli.flushall()orcli.flushdb()?
– Benyamin Jafari
Nov 13 '18 at 14:18
The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands
– Itamar Haber
Nov 13 '18 at 21:00
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You're storing in Redis an object (dict_) under the key called 'pythonDict'. Just call cli.delete("pythonDict") to delete it.
Thanks a lot. It works.
– Benyamin Jafari
Nov 13 '18 at 14:15
What is the difference between this line andcli.flushall()orcli.flushdb()?
– Benyamin Jafari
Nov 13 '18 at 14:18
The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands
– Itamar Haber
Nov 13 '18 at 21:00
add a comment |
You're storing in Redis an object (dict_) under the key called 'pythonDict'. Just call cli.delete("pythonDict") to delete it.
Thanks a lot. It works.
– Benyamin Jafari
Nov 13 '18 at 14:15
What is the difference between this line andcli.flushall()orcli.flushdb()?
– Benyamin Jafari
Nov 13 '18 at 14:18
The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands
– Itamar Haber
Nov 13 '18 at 21:00
add a comment |
You're storing in Redis an object (dict_) under the key called 'pythonDict'. Just call cli.delete("pythonDict") to delete it.
You're storing in Redis an object (dict_) under the key called 'pythonDict'. Just call cli.delete("pythonDict") to delete it.
edited Nov 13 '18 at 14:17
Benyamin Jafari
2,94632139
2,94632139
answered Nov 13 '18 at 14:10
Itamar HaberItamar Haber
28.5k43760
28.5k43760
Thanks a lot. It works.
– Benyamin Jafari
Nov 13 '18 at 14:15
What is the difference between this line andcli.flushall()orcli.flushdb()?
– Benyamin Jafari
Nov 13 '18 at 14:18
The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands
– Itamar Haber
Nov 13 '18 at 21:00
add a comment |
Thanks a lot. It works.
– Benyamin Jafari
Nov 13 '18 at 14:15
What is the difference between this line andcli.flushall()orcli.flushdb()?
– Benyamin Jafari
Nov 13 '18 at 14:18
The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands
– Itamar Haber
Nov 13 '18 at 21:00
Thanks a lot. It works.
– Benyamin Jafari
Nov 13 '18 at 14:15
Thanks a lot. It works.
– Benyamin Jafari
Nov 13 '18 at 14:15
What is the difference between this line and
cli.flushall() or cli.flushdb()?– Benyamin Jafari
Nov 13 '18 at 14:18
What is the difference between this line and
cli.flushall() or cli.flushdb()?– Benyamin Jafari
Nov 13 '18 at 14:18
The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands
– Itamar Haber
Nov 13 '18 at 21:00
The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands
– Itamar Haber
Nov 13 '18 at 21:00
add a comment |