An in-memory datastore in node for Redis™1 compatible clients
Supports:
- authentication
- expiry (expire, ttl, pexpire, pttl, ...)
- strings (set, mset, get, mget, ...)
- hashes (hset, hmset, hget, hgetall, ...)
- list (lindex, llen, lpop, lpush [], ...)
- publish/ subscribe (publish, subscribe, psubscribe, ...)
- persistence
Does not (yet) support:
- transactions (rollback on error)
- sets
- streams
- partitioning
- replication
npm i sider-mem
start the server
npx sider-mem --port 6379 --user alice --password somepassword
const { Server } = require('sider-mem')
// start the server
const server = new Server({username: 'alice', password: 'somepassword'})
await server.listen({ port: 6379 })
// ...
// disconnect
await server.close()
connect with client
const redis = require('redis')
const client = redis.createClient({user: 'alice', password: 'somepassword'})
client.ping((err, data) => console.log(data)) // PONG
See example for use with a clustered app.
Start with npm run example
and browse to http://localhost:3000
Option | default | Description |
---|---|---|
username | "default" | Enables authentication |
password | - | |
log | debug-level | Changes logger; e.g. to use console logging () => console |
gracefulTimeout | 100 | (ms) Server timeout on shutdown |
nextHouseKeepingSec | 30 | (s) Housekeeping interval for cleanup of expired keys |
dbDir | - | Persistence: database directory for append only files |
HashMap | Map | Use a different hash-map implementation than ES6 Map. See src/HampMap.js and src/MegaMap.js for possible implementations |
Option | default | Description |
---|---|---|
port | 6379 | Listening Port |
host | 127.0.0.1 | Set to 0.0.0.0 to accept incoming connections from any host |
Supported commands ⏬
- append
- auth
- client
- command
- decr
- decrby
- del
- echo
- exec
- exists
- expire
- expireat
- expiretime
- flushall
- flushdb
- get
- getdel
- getex
- getrange
- getset
- hdel
- hello
- hexists
- hget
- hgetall
- hincrby
- hincrbyfloat
- hkeys
- hlen
- hmget
- hmset
- hscan
- hset
- hsetnx
- hstrlen
- hvals
- incr
- incrby
- incrbyfloat
- info
- lindex
- llen
- lpop
- lpos
- lpush
- lpushx
- lrange
- lrem
- lset
- ltrim
- mget
- mset
- msetnx
- multi
- persist
- pexpire
- pexpireat
- pexpiretime
- ping
- psetex
- psubscribe
- pttl
- publish
- pubsub
- punsubscribe
- quit
- rpop
- rpush
- rpushx
- scan
- select
- set
- setex
- setnx
- setrange
- shutdown
- strlen
- subscribe
- substr
- ttl
- type
- unsubscribe
Footnotes
-
Redis is a trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. Any use by this documentation is for referential purposes only and does not indicate any sponsorship, endorsement or affiliation between Redis and the author(s). ↩