Redis Tutorial Part 4– Redis Data structures setting expiration time for key with Node.js ioredis
linux , databases , redis / April 24, 2019

Setting  expiration time for a data in Redis Consider an object which contains name and type. We store this data in Redis using the Redis hashes data structure.

We store this data into a key called listdb using the following code

hset is used to set a key and corresponding value in the hash.   Now we set the expiration time for  key listdb using expire

In this code 60 represent the expiration time in seconds. You can change this value as you want On running this code to get the value after the 60s will give empty data

hgetall will get all the values  for key listdb Running this code before 60 s will give a result like this


Share this page in social media platforms