In my redis database I have a key:
127.0.0.1:6379[5]> get "263384DB-61DD561800016316-240C0700"
"{\"json\":{\"created\":\"1641895448090335\",\"last_signal\":\"1641895448\",\"tos\":\"184\",\"deleted\":\"0\",\"num_sfds\":\"4\",\"num_streams\":\"4\",\"num_medias\":\"2\",\"num_tags\":\"2\",\"num_maps\":\"2\",\"ml_deleted\":\"0\",\"created_from\":
... about 6300 chars
I try
127.0.0.1:6379[5]> del "263384DB-61DD561800016316-240C0700"
(integer) 1
I also tried:
127.0.0.1:6379[5]> DEL `"263384DB-61DD561800016316-240C0700"`
Invalid argument(s)
127.0.0.1:6379[5]> DEL '"263384DB-61DD561800016316-240C0700"'
(integer) 0
but value is still there:
127.0.0.1:6379[5]> get "263384DB-61DD561800016316-240C0700"
"{\"json\":{\"created\":\"1641895448090335\",\"last_signal\":\"1641895448\",\"tos\":\"184\",\"deleted\":\"0\",\"num_sfds\":\"4\",\"num_streams\":\"4\",\"num_medias\":\"2\",\"num_tags\":\"2\",\"num_maps\":\"2\",\"ml_deleted\":\"0\",\"created_from\"
... about 6300 chars
TTL is 24 hours, but key is 20 or more days old. What could be the reason?
Now I also tried
UNLINK "263384DB-61DD561800016316-240C0700"
(integer) 1
key still exists.
I am not sure why you continue trying to delete your key after you run:
server:6379> del "263384DB-61DD561800016316-240C0700"
and get a successful result of:
(integer) 1
In order to debug it, start another Terminal session and run Redis's MONITOR command:
redis-cli MONITOR
then you can see all the commands coming into Redis.
Also, try running this in your original session, to see the key's "Time-to-Live", both before and after attempting to delete the key:
server:6379> ttl "263384DB-61DD561800016316-240C0700"
Comment from Mark was helpful. It seams the key is written again every 5 seconds: (Query every few seconds)
127.0.0.1:6379[5]> ttl "263384DB-61DD561800016316-240C0700" (integer) 86395 127.0.0.1:6379[5]> ttl "263384DB-61DD561800016316-240C0700" (integer) 86399 127.0.0.1:6379[5]> ttl "263384DB-61DD561800016316-240C0700" (integer) 86398 127.0.0.1:6379[5]> ttl "263384DB-61DD561800016316-240C0700" (integer) 86398 127.0.0.1:6379[5]> ttl "263384DB-61DD561800016316-240C0700" (integer) 86398 127.0.0.1:6379[5]> ttl "263384DB-61DD561800016316-240C0700" (integer) 86395 127.0.0.1:6379[5]> ttl "263384DB-61DD561800016316-240C0700" (integer) 86397 127.0.0.1:6379[5]> ttl "263384DB-61DD561800016316-240C0700" (integer) 86400
from redis-cli MONITOR:
1651147523.327082 [5 127.0.0.1:53408] "EXPIRE" "263384DB-61DD561800016316-240C0700" "86400" 1651147528.326984 [5 127.0.0.1:53408] "SET" "263384DB-61DD561800016316-240C0700" "{\"json\":{\"created\":\"1641895448090335...
so this is not a REDIS issue, it is the software writing the keys (rtp engine)
Related
i can view global total key created by sets by just execute command "redis-cli info keyspace", but redis List not listed by that command only total Keys. how do i see global total lists inside my server (not only 1 specific list) ?
example List not listed in "info keyspace" only keys (2 additional push to 2 list, but the still in 78.106 keys) :
127.0.0.1:6379> info keyspace
# Keyspace
db0:keys=78106,expires=20,avg_ttl=10922697
127.0.0.1:6379> rpush TEST20220328B fulan
(integer) 2
127.0.0.1:6379> rpush TEST20220328 similikiti2
(integer) 2
127.0.0.1:6379> info keyspace
# Keyspace
db0:keys=78106,expires=20,avg_ttl=12895288
example keys listed in info keyspace (total keys raised from 78.106 to 78.107) :
127.0.0.1:6379> set Test ABCD
OK
127.0.0.1:6379> info keyspace
# Keyspace
db0:keys=78107,expires=20,avg_ttl=12656256
127.0.0.1:6379>
When I scan entire redis instance using redis-cli --bigkeys following shortened result is returned
-------- summary -------
Sampled 241145 keys in the keyspace!
Total key length in bytes is 13013217 (avg len 53.96)
Biggest string found 'celery-task-meta-52b14b66-b924-4c40-b7dc-7d5b9b633470' has 6510 bytes
**Biggest list found 'celery9' has 156519 items**
Biggest set found '_kombu.binding.celeryev' has 52 members
Biggest hash found 'unacked' has 544 fields
Biggest zset found 'unacked_index' has 550 members
As you can see my biggest list is celery9 with length 156519. I am using only one keyspace
127.0.0.1:6379> info keyspace
# Keyspace
db0:keys=256672,expires=256659,avg_ttl=1701804
But when I connect to redis instance using redis-cli or even with redis connector from python and run following commands
127.0.0.1:6379> get celery9
(nil)
127.0.0.1:6379> llen celery9
(integer) 0
127.0.0.1:6379>
nil or zero is returned as if there was no key celery9.
So the question is, how to get correct length of this key? All others keys are working perfectly
I'm new to Redis so this will be a rudimentary question.
I'm considering creating a Redis job queue using a list. The jobs themselves will be JSON-encoded objects.
I realize that I can use LPOP and RPUSH for managing the queue. I can even use RPOPLPUSH when using multiple lists (e.g "Queued", "Processing" and "Completed").
Let's say I have a worker that processes images by steadily going through the "Queued" list. Then let's say the client has deleted an image from the front-end, before that particular job has even begun to process. How do I delete this job from the "Queued" list so the worker doesn't waste time processing it?
In other words, how can I index individual jobs in a job queue?
use a sorted set with the timestamp as the score and you can remove a job
$ redis-cli zadd myjobs `date +"%s.%N"` job1
$ redis-cli zadd myjobs `date +"%s.%N"` job2
$ redis-cli zadd myjobs `date +"%s.%N"` job3
$ redis-cli
127.0.0.1:6379> ZRANGEBYSCORE myjobs -inf +inf WITHSCORES
1) "job1"
2) "1638908693.1293526"
3) "job2"
4) "1638908696.5061705"
5) "job3"
6) "1638908699.2742543"
127.0.0.1:6379> ZREMRANGEBYLEX myjobs [job2 [job2
(integer) 1
127.0.0.1:6379> ZRANGEBYSCORE myjobs -inf +inf WITHSCORES
1) "job1"
2) "1638908693.1293526"
3) "job3"
4) "1638908699.2742543"
I mean is there a command used to check whether a redis command is readonly?
is_readonly(command)
It will better if there is command in Jedis.
with COMMAND you can get list of all commands with command flags such as
readonly
so here's the list I've end up with:
publish bgsave sunion readonly exists hstrlen lindex scan ping latency ttl wait zscore zrevrangebylex sscan geohash getbit hkeys zrange monitor llen save auth zcard shutdown sync dbsize subscribe zrangebylex zlexcount mget getrange bitpos config lrange replconf discard asking client pfselftest bgrewriteaof unsubscribe zrank readwrite hget bitcount randomkey time zrevrank sinter dump strlen unwatch smembers georadius lastsave slowlog sismember hexists multi sdiff geopos hscan script keys hvals pfcount zscan echo command select zcount substr pttl hlen info scard geodist srandmember hgetall cluster psync pubsub psubscribe zrevrange hmget object watch zrangebyscore get type zrevrangebyscore punsubscribe georadiusbymember
though you might want to exclude readonly admin commands - they don't change data but can cause side effects. here's list with excluded admin:
publish sunion readonly exists hstrlen lindex scan ping ttl wait zscore zrevrangebylex sscan geohash getbit hkeys zrange llen auth zcard dbsize subscribe zrangebylex zlexcount mget getrange bitpos lrange discard asking client pfselftest unsubscribe zrank readwrite hget bitcount randomkey time zrevrank sinter dump strlen unwatch smembers georadius lastsave slowlog sismember hexists multi sdiff geopos hscan script keys hvals pfcount zscan echo command select zcount substr pttl hlen info scard geodist srandmember hgetall pubsub psubscribe zrevrange hmget object watch zrangebyscore get type zrevrangebyscore punsubscribe georadiusbymember
more here: http://redis.io/commands/command#examples
I think you might also check which commands is available for specific redis server version.
redis 127.0.0.1:6379> zadd somekey 12.54 value
(integer) 1
redis 127.0.0.1:6379> zrevrange somekey 0 -1 withscores
1) "value"
2) "12.539999999999999"
How do I keep the original number format in redis?
Redis relies on client for number precision conversion, so this might not be possible to achieve using Redis default cli using python.
A similar thread for same :
http://www.manning-sandbox.com/thread.jspa?messageID=159190