Redis
 sql >> डेटाबेस >  >> NoSQL >> Redis

नोड के साथ रेडिस एक्सपायर इवेंट कैसे प्राप्त करें?

विशिष्ट चैनल ('example@sqldat.com__:expired' के सब्सक्राइब्ड क्लाइंट का उपयोग करके "एक्सपायर्ड" टाइप कीइवेंट नोटिफिकेशन को सुनना वास्तव में संभव है। ) और उसका संदेश सुनना घटना।

setInterval / setTimeout या अतिरिक्त पुस्तकालयों की कोई आवश्यकता नहीं है

अवधारणा का प्रमाण (काम कर रहे:NodeJS v.9.4.0 के साथ परीक्षण किया गया) )

const redis = require('redis')
const CONF = {db:3}
var pub, sub
//.: Activate "notify-keyspace-events" for expired type events
pub = redis.createClient(CONF)
pub.send_command('config', ['set','notify-keyspace-events','Ex'], SubscribeExpired)
//.: Subscribe to the "notify-keyspace-events" channel used for expired type events
function SubscribeExpired(e,r){
 sub = redis.createClient(CONF)
 const expired_subKey = 'example@sqldat.com'+CONF.db+'__:expired'
 sub.subscribe(expired_subKey,function(){
  console.log(' [i] Subscribed to "'+expired_subKey+'" event channel : '+r)
  sub.on('message',function (chan,msg){console.log('[expired]',msg)})
  TestKey()
 })
}
//.: For example (create a key & set to expire in 10 seconds)
function TestKey(){
 pub.set('testing','redis notify-keyspace-events : expired')
 pub.expire('testing',10)
}


  1. Redis
  2.   
  3. MongoDB
  4.   
  5. Memcached
  6.   
  7. HBase
  8.   
  9. CouchDB
  1. रेडिस क्लस्टर के साथ, हैश टैग को निकालने के लिए केवल पास करना संभव है?

  2. जेडिस रेडिस के शब्दार्थ को बदल रहा है?

  3. रेडिस में एक जटिल वस्तु को कैसे स्टोर करें (रेडिस-पीई का उपयोग करके)

  4. रेडिस सीरियलाइज़ेशन और डिसेरिएलाइज़ेशन

  5. हमारे मास्टर डेटाबेस के रूप में MongoDB का उपयोग करते हुए, क्या मुझे संस्थाओं के बीच संबंधों को लागू करने के लिए एक अलग ग्राफ डेटाबेस का उपयोग करना चाहिए?