Reputation: 95
I am consuming a redis
list like this in python
:
listitem = r.rpoplpush('mylist','mylist')
Strangely, the list gets empty randomly - for instance it will work without getting emptied for a month and then one fine day get emptied? What am I missing here? There is no other statement in my script which touches the script any way.
Upvotes: 1
Views: 827
Reputation: 6764
There is no such thing as an empty list in Redis, if a list is RPOP'ed all the way, the key is deleted.
So, one of these should be happening:
mylist
is getting emptied (LPOP, RPOP, LREM, LTRIM, etc) all the way until empty.mylist
is being deleted (DEL, UNLINK, etc)mylist
is being expired (EXPIRE, EXPIREAT, etc)If no redis-client is touching the key (1-3), then it must be 4 or 5.
See if you have some eviction policy set in your server with CONFIG GET maxmemory-policy
.
Data loss may be occurring if you have no persistence and your server is restarted. Or if you are using more than a single instance (cluster or sentinel) and something is wrong. You can use the INFO
command to see:
redis_mode
and uptime_in_days
.maxmemory_policy
and evicted_keys
will tell us if a policy is being appliedUpvotes: 2