jsredis
A lightweight, high performance in-memory database based on redis. Makes use of the latest ES2015 features (such as Map).
Getting Started
Install it via npm:
npm install jsredis
And include in your project:
;
Usage and Commands
The biggest difference to this and using an actual redis instance is that you can use any type for a hash, field or value, so if you wished you could store functions, classes, arrays, numbers, objects ... etc and not just strings.
All the commands are synchronous, therefore can all be run inline.
BASIC EXAMPLE:
const db = ; if db console; // logs 'value' console; // logs [ 'field' ] console; // logs [ 'value' ] console; // logs [ [ 'field','value' ] ] console; // logs 1 console; // logs 1 console; // logs 0
Currently Available Commands
- FLUSHDB
- SET
- GET
- SETNX
- APPEND
- STRLEN
- EXISTS
- TYPE
- DEL
- HGET
- HSET
- HSETNX
- HDEL
- HKEYS
- HVALS
- HLEN
- HEXISTS
- HGETALL
- HSTRLEN
Contributing / TODO
If you feel like contributing feel free to fork, make changes and submit a PR.
TODO
- sets (use es6 Set?)
- zsets
- lists (use es6 Set?)
- expires / ttl etc (thinking lazy key expiry, but would potentially slow other get transactions, suggestions?)
- tests tests tests \o/
- docs
- benchmarks
Benchmarks
Still polishing the benchmark scripts but, initial tests have shown the following:
set
completes1 million
transactions in~600-700ms
setnx
completes1 million
transactions in~80ms
- where exists is truesetnx
completes1 million
transactions in~900ms
- where exists is falseget
completes1 million
transactions in~90ms
on a key that doesn't existget
completes1 million
transactions in~90ms
on a key that exists, pretty much the same result as aboveexists
completes1 million
transactions in~80ms
- pretty much same results if key exists or nothset
on a single hash for all transactions1 million
transactions in~700-800ms
hset
on a on new hash per transaction completes1 million
transactions in~8000-9000ms
License
MIT