Nutritious Pumpkin Masses

    @hakrac/redisutils

    0.0.6 • Public • Published

    High level redis utility

    A high level redis node js utility based on node-redis.

    RedisPubSub

    Publish/Subscribe pattern built into node js EventEmitter.

    To subscribe run

    const brokerA = new RedisPubSub({
        redisUrl: "redis://localhost"
    })
    
    brokerA.on("PING", message => {
        console.log(`Emitted ${message} on PING event`)
    })

    You can now connect to the same redis server and emit the event PING from anywhere.

    const brokerB = new RedisPubSub({
        redisUrl: "redis://localhost"
    })
    
    brokerB.emit("PING", JSON.stringify({hello: "hello"}))

    RedisStream

    Utilizes an underlying redis stream to distribute messages in a queue.

    const stream = new RedisStream(
        ["mystream"],    // all streams to listen on for events
        "mygroup1",      // consumer group
        "myconsumer",    // consumer name
        "event",         // event key
        redis.createClient("redis://localhost"), 
        redis.createClient("redis://localhost")
    )
    stream.add({event: "mystream"}, "mystream")

    RedisStore

    Acts as a simple dictionary store.

    const configStore = new RedisStore({
        redisUrls: "redis://localhost"
    })
    
    configStore["foo"] = "bar"
    
    configStore["foo"]
        .then(console.log)
    // bar

    Keywords

    none

    Install

    npm i @hakrac/redisutils

    DownloadsWeekly Downloads

    3

    Version

    0.0.6

    License

    ISC

    Unpacked Size

    10.3 kB

    Total Files

    14

    Last publish

    Collaborators

    • hakrac