question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how expire key with callback

See original GitHub issue
var Redis        = require('ioredis');
redis = new Redis();

var key = 'expire_test';
var content ='content'
var timeout = 10;

redis.multi()
.set(key, content)
.expire(key, timeout, function(){
  console.log('out');
})
.exec(function(err) {
  if(err) {
    console.error("Failed to publish EXPIRE EVENT for " + content);
    console.error(err);
    return;
  }
});

like this?

.expire(key, timeout, function(){
  console.log('out');
})

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
luincommented, Sep 30, 2015

这个没法实现到期提醒,只能实现删除提醒。比如 expire 一个键 100 秒过期,Redis 不会恰好在第一百秒删除这个键,而是在下一次访问这个键或者后台垃圾回收时才会真正删除它

1reaction
damianobarbaticommented, Jun 26, 2018

Hey guys, can you explain what’s the final behaviour?

redis.set(key, content, 'EX', timeout, function (err, res) {
 is this execute right when the key is EXPIRED?
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get callback when key expires in REDIS
I'm storing this key in REDIS with expiry of 4 days. If user does not confirm email within 4 days, key gets expired....
Read more >
Redis — Getting Notified When a Key is Expired or Changed
Key expiration IS NOT REAL TIME, while it seems like a real time if you try on local (small key), it's already stated...
Read more >
Callback when a key expires · Issue #529 · dgraph-io/badger
There's no exact moment in time when a key is deleted. If a key is expired, Badger would just not return it anymore,...
Read more >
How to write your own Redis key expire listener in Python
How to write your own Redis key expire listener in Python · Run below command redis-cli config set notify-keyspace-events Ex · Update Redis...
Read more >
EXPIRE
It is possible to call EXPIRE using as argument a key that already has an existing expire set. In this case the time...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found