0.2.1 • Published 5 years ago

redis-liveset v0.2.1

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
5 years ago

Redis LiveSet

A type-safe Redis wrapper to keep a Set eventually synchronized across multiple nodes.

Installation

npm install --save redis-liveset

Usage examples

Listening for updates

import { createNumbersLiveSet } from "redis-liveset"
import * as redis from "redis"
import { Set } from "immutable"

const sub = redis.createClient()
const pub = redis.createClient()

const liveSet = createNumbersLiveSet("my-super-channel", pub, sub)

liveSet.subscribe((s: Set<number>) => {
  console.log("Set changed: ", s)
})

Changing Set

import { createNumbersLiveSet } from "redis-liveset"
import * as redis from "redis"

const sub = redis.createClient()
const pub = redis.createClient()

const liveSet = createNumbersLiveSet("my-super-channel", pub, sub)
liveSet.clear()
liveSet.replaceAll([5,6,7])
liveSet.add(1)
liveSet.addAll([10,11])
liveSet.remove(5)

Contribute

Perfection is Achieved Not When There Is Nothing More to Add, But When There Is Nothing Left to Take Away

Fork, Contribute, Push, Create pull request, Thanks.