Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you have could work, but depends on how big you expect your data set to get. If I understand correctly, your current implementation will require you to run a worker pinging every key with tick(). This would be very, very expensive in terms of network back-and-forth in your current implementation since you'd have to go over the network, query Redis, and send the results back for every single key (possibly two queries if you need to update). If it's just for the two keys you mention, that's fine. If it's for more, <a href="http://redis.io/topics/pipelining" rel="nofollow">pipelines are your friend</a>. </p> <p>If you wanted to be more elegant and robust, you could use <a href="http://redis.io/topics/notifications" rel="nofollow">notifications</a> when your keys expire. The paradigm here would be, for each value you would set two keys: <code>k</code>, and <code>k_updated</code>. <code>k</code> would hold the actual value for the key, and <code>k_updated</code> would just be a dumb key with a TTL set for when you want <code>k</code> to be updated. When <code>k_updated</code> expires, you'll get a notification, and you can have a listener then immediately process this as a request for a new job to update <code>k</code> and set a new <code>k_updated</code>. This would use the <a href="http://redis.io/topics/pubsub" rel="nofollow">pubsub</a> model, and you could have multiple subscribers and use a Queue to manage the new jobs, if you wanted to be very robust about it. The benefits of this system:</p> <ol> <li><p>Keys will get updated immediately when they expire with no need to constantly query them to see if they need to be updated.</p></li> <li><p>You can have multiple independent workers subscribed and listening for update tasks and manage new update jobs as they come in, so that if one update worker goes down, you don't lose updating until you bring the box back up.</p></li> </ol> <p>This latter system could be overkill for your case if you don't have extreme speed or robustness needs, but if you do or plan to, it's something to consider. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload