Skip to content

sandro-pasquali/fink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fink

Subscribe to Redis keyspace notifications.

Installation

require('fink')([options]).then(finkAPI => { ... })

Note that you are working with a Promise.

You will need Redis >=2.8 installed.

To use keyspace notifications you must enable them in Redis (for example via redis-cli> config set notify-keyspace-events KEA). They are not enabled in Redis by default.

Consult the Redis documentation.

Options

Options for fink track those for the redis module. You are setting options for the Redis client here.

Testing

npm test

If you have a password on your db, you will need to modify the test suite to accomodate that. Same if Redis is not @ localhost:6379.

Usage

fink returns a Promise.

let fink = require('fink')(<redis options>)

fink.then(finkApi => { 

    finkApi.subscribe((keyspace | keyevent), [key || eventName]);
    ...
    finkApi.unsubscribe((keyspace | keyevent), [key || eventName]);  
    ...
    finkApi.on('message', (msg) => {
    
        // Given : finkApi.subscribe('keyspace', 'foo')
        // On : someRedisClient.set('foo', 1)
        // #msg looks like:
        //
        {   type: 'keyspace',
            db: '0',
            pattern: '__keyspace@0__:foo',
            channel: '__keyspace@0__:foo',
            key: 'foo',
            event: 'set' 
        }
    }
}

If second argument is not sent to subscribe subscription will be to all keyspace or keyevent events.

About

Redis keyspace change notifier

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages