Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lostintime/node-redis-liveset
A type-safe Redis wrapper to keep a Set eventually synchronized across multiple nodes.
https://github.com/lostintime/node-redis-liveset
nodejs redis typescript
Last synced: about 1 month ago
JSON representation
A type-safe Redis wrapper to keep a Set eventually synchronized across multiple nodes.
- Host: GitHub
- URL: https://github.com/lostintime/node-redis-liveset
- Owner: lostintime
- License: apache-2.0
- Created: 2017-12-05T08:24:29.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-27T16:15:14.000Z (over 3 years ago)
- Last Synced: 2024-09-28T00:22:04.448Z (about 2 months ago)
- Topics: nodejs, redis, typescript
- Language: TypeScript
- Size: 33.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Redis LiveSet
=============A type-safe Redis wrapper to keep a [Set](https://redis.io/topics/data-types#sets) _eventually_ synchronized across multiple nodes.
## Installation
```bash
npm install --save redis-liveset
```## Usage examples
Listening for updates
```typescript
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) => {
console.log("Set changed: ", s)
})
```Changing Set
```typescript
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 AwayFork, Contribute, Push, Create pull request, Thanks.