Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsredis

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsredis

A lightweight, high performance in-memory database based on redis. Makes use of the latest ES2015 features (such as Map).

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

jsredis

Coverage Downloads Downloads npm version node version dependencies dev dependencies License

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:

import Database from 'jsredis';

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 = new Database();

if (db.hsetnx('hash', 'field', 'value')) {
  console.log(db.hget('hash', 'field')); // logs 'value'
  console.log(db.hkeys('hash')); // logs [ 'field' ]
  console.log(db.hvals('hash')); // logs [ 'value' ]
  console.log(db.hgetall('hash')); // logs [ [ 'field','value' ] ]
  console.log(db.hlen('hash')); // logs 1
  console.log(db.flushdb()); // logs 1
  console.log(db.hlen('hash')); // 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 completes 1 million transactions in ~600-700ms
  • setnx completes 1 million transactions in ~80ms - where exists is true
  • setnx completes 1 million transactions in ~900ms - where exists is false
  • get completes 1 million transactions in ~90ms on a key that doesn't exist
  • get completes 1 million transactions in ~90ms on a key that exists, pretty much the same result as above
  • exists completes 1 million transactions in ~80ms - pretty much same results if key exists or not
  • hset on a single hash for all transactions 1 million transactions in ~700-800ms
  • hset on a on new hash per transaction completes 1 million transactions in ~8000-9000ms

alt text

License

MIT

Keywords

FAQs

Package last updated on 09 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc