npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redis2go

v1.0.2

Published

A minimal redis implementation of a subset of its functionalities in JS.

Downloads

4

Readme

Redis2Go

Build Status npm version

This is a implementation of a subset of Redis commands. In particular:

  1. SET key value
  2. SET key value EX seconds (need not implement other SET options)
  3. GET key
  4. DEL key
  5. DBSIZE
  6. INCR key
  7. ZADD key score member
  8. ZCARD key
  9. ZRANK key member
  10. ZRANGE key start stop

Lightweight Architecture Decision Records

We use ADRs, so major decisions are justified and put on context for future consideration.

Installation in your Project

You'll need Node v6.10.3 and npm. This packaged it's published on NPM, so you can add it to your JS projects.

npm install redis2go --save

Usage Example


const Redis2Go = require('./redis2go')
const client = new Redis2Go()

client.set(100).then(result => console.log(result)) // 'OK'


client.get('my_key').then(result => console.log(result)) // '100'
 

JS API of Available Commands

For behavior of each command, check the Command Reference.

GET

 get(key) -> Promise

SET

 set(key, value, expiration_time) -> Promise

DEL

 del(...args) -> Promise

INCR

 incr(key) -> Promise

DBSIZE

 dbsize() -> Promise

ZADD

 zadd(key, [... order, value]) -> Promise

ZCARD

 zcard(key) -> Promise

ZRANK

 zrank(key, value) -> Promise

ZRANGE

 zrange(key, start, end) -> Promise

Server

To start a server instance:

npm run start

You can specify which port to run by setting the environment variable PORT, by default it will run in the port 3000.

Command Mode

You can run raw commands with query parameters:

curl localhost:8080/?cmd=SET%20mykey%20cool-value
OK
curl localhost:8080/?cmd=GET%20mykey
cool-value
curl localhost:8080/?cmd=DEL%20mykey
OK
curl localhost:8080/?cmd=GET%20mykey
(nil)

HTTP API

For a more idiomatic way of communicating with Redis2go, we have a Full Rest API.

Make sure to add Content-Type: text/plain as it is the data type that the API will consume.

ADD

method: 'PUT',
path: '/{key}',

GET

method: 'GET',
path: '/{key}',

DELETE

method: 'DELETE',
path: '/{key}',

DBSIZE

method: 'GET',
path: '/dbSize',

INCR

method: 'PUT',
path: '/{key}/incr',

ZADD

method: 'PUT',
path: '/{key}/zadd',

ZCARD

method: 'GET',
path: '/{key}/zcard',

ZRANK

method: 'GET',
path: '/{key}/zrank/{value}'

ZRANGE

method: 'GET',
path: '/{key}/zrange/{start}/{end}',

Example

curl -X POST -H "Content-Type: text/plain" --data "cool-value" -X PUT localhost:3000/mykey

Tests

To run unit tests, clone this repo and run the following:

npm install
npm run test

To run integration tests:

npm install
npm run start

#different terminal, run the tests
npm run integration-tests