Coder Social home page Coder Social logo

redis-types's Introduction

redis-types

redis type objects - hashes, lists, sets, etc

Installation

npm install redis-types

Usage

Uses redis node module under the hood. Syntax is identical except that the redis-key is specified through the constructor.

Key

  • DEL
  • DUMP
  • EXISTS
  • EXPIRE
  • EXPIREAT
  • MOVE
  • PERSIST
  • PEXPIRE
  • PEXPIREAT
  • PTTL
  • RENAME
  • RENAMENX
  • RESTORE
  • SORT
  • TTL
  • TYPE
  • Lowercase works too
var RedisKey = require('redis-types').Key;
var redisKey = new RedisKey('foo');
redisKey.del(function (err, success) {
  // ...
});

Strings

  • Inherits from Keys
  • APPEND
  • BITCOUNT
  • BITOP
  • BITPOS
  • DECR
  • DECRBY
  • GET
  • GETBIT
  • GETRANGE
  • GETSET
  • INCR
  • INCRBY
  • INCRBYFLOAT
  • MGET
  • MSET
  • MSETNX
  • PSETEX
  • SET
  • SETBIT
  • SETEX
  • SETNX
  • SETRANGE
  • STRLEN
  • Lowercase works too
var RedisString = require('redis-types').String;
var redisString = new RedisString('foo');
redisString.set('bar', function (err, success) {
  // ...
});

Lists

  • Inherits from Keys
  • BLPOP
  • BRPOP
  • BRPOPLPUSH
  • LINDEX, INDEX
  • LINSERT, INSERT
  • LLEN, LEN
  • LPOP
  • LPUSH
  • LPUSHX
  • LRANGE
  • LREM
  • LSET, SET
  • LTRIM
  • RPOP
  • RPOPLPUSH
  • RPUSH
  • RPUSHX
  • Lowercase works too
var RedisList = require('redis-types').RedisList;
var fooList = new RedisList('foo');
fooList.rpush("1", function (err) {
  fooList.rpush("2", function (err) {
    fooList.rpush("3", function (err) {
      fooList.lrange(0, -1, function (err, items) {
        console.log(items); // ["1", "2", "3"]
      });
    });
  });
});

Hashes

  • Inherits from Keys
  • HDEL, DEL
  • HEXISTS, EXISTS
  • HGET, GET
  • HGETALL, GETALL
  • HINCRBY, INCRBY
  • HINCRBYFLOAT, INCRBYFLOAT
  • HKEYS, KEYS
  • HLEN, LEN
  • HMGET, MGET
  • HMSET, MSET
  • HSET, SET
  • HSETNX, SETNX
  • HVALS, VALS
  • HSCAN, SCAN
  • Lowercase works too
var RedisHash = require('redis-types').RedisHash;
var fooHash = new RedisHash('foo');
fooHash.hset("bar", "1", function (err) {
  fooList.hget("bar", function (err, val) {
    console.log(val); // "1"
  });
});

Set

  • Inherits from Keys
  • SADD, ADD
  • SCARD, CARD
  • SDIFF, DIFF
  • SDIFFSTORE, DIFFSTORE
  • SINTER, INTER
  • SINTERSTORE, INTERSTORE
  • SISMEMBER, ISMEMBER
  • SMEMBERS, MEMBERS
  • SMOVE, MOVE
  • SPOP, POP
  • SRANDMEMBER, RANDMEMBER
  • SREM, REM
  • SUNION, UNION
  • SUNIONSTORE, UNIONSTORE
  • SSCAN, SCAN
  • Lowercase works too
var RedisSet = require('redis-types').RedisSet;
var fooSet = new RedisSet('foo');
fooSet.sadd("1", function (err) {
  fooSet.spop(function (err, val) {
    console.log(val); // "1"
  });
});

SortedSet

  • Inherits from Keys
  • ZADD, ADD
  • ZCARD, CARD
  • ZCOUNT, COUNT
  • ZINCRBY, INCRBY
  • ZINTERSTORE, INTERSTORE
  • ZLEXCOUNT, LEXCOUNT
  • ZRANGE, RANGE
  • ZRANGEBYLEX, RANGEBYLEX
  • ZRANGEBYSCORE, RANGEBYSCORE
  • ZRANK, RANK
  • ZREM, REM
  • ZREMRANGEBYLEX, REMRANGEBYLEX
  • ZREMRANGEBYRANK, REMRANGEBYRANK
  • ZREMRANGEBYSCORE, REMRANGEBYSCORE
  • ZREVRANGE, REVRANGE
  • ZREVRANGEBYSCORE, REVRANGEBYSCORE
  • ZREVRANK, REVRANK
  • ZSCORE, SCORE
  • ZUNIONSTORE, UNIONSTORE
  • ZSCAN, SCAN
  • Lowercase works too
var RedisSortedSet = require('redis-types').RedisSortedSet;
var fooSortedSet = new RedisSortedSet('foo');
fooSortedSet.zadd("1", function (err) {
  fooSortedSet.zrange(0, -1, function (err, items) {
    console.log(items); // ["1"]
  });
});

Pub/Sub

Not yet implemented

License

MIT

redis-types's People

Contributors

tjmehta avatar

Watchers

Bryan Kendall avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.