0.0.16 • Published 6 years ago

pea-redis v0.0.16

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

npm package

Features

Pea-redis is based on ioredis, it support async/await usage,it's a further encapsulated and functionally extended functional class. Based on the basic functions of ioredis, it adds operations on objects, and hash, making it easier for Nodejs developers to operate redis.

  1. set/get hset/hget Object into/from redis, easy for Nodejs developer to use
  2. it support async/await usage

Quick Start

Install

$ npm i pea-redis

Basic Usage

set/get Object

await peaRedis.set('a',{'a':1});
const a = await peaRedis.get('a'); // a = {'a':1}

set/get Value

await peaReids.setValue('b', 'this is string');
const c = await peaReids.getValue('b'); // b = this is string;

hset/hget Object

await peaRedis.hset('c','c',{c:1});
const b = await peaRedis.hget('c', 'c'); // c = {c:1}

hset/hget Value

await peaRedis.hsetValue('d','d','d');
const b = await peaRedis.hgetValue('d', 'd'); // d

If you want to delete some cache in the redis, it's more easier than ioredis

For example:

await hdel('obj', 'b');

await del('a');

If you want to use the native method of ioredis, you only need to get the ioredis object and then you can use any ioredis method which you want

For example:

// get ioredis object
const ioRedis = peaRedis.getRedis();

// you can use the native method of ioredis through ioRedis object
ioRedis.set('foo', 'bar');
ioRedis.get('foo', function (err, result) {
  console.log(result);
});

...

see more ioRedis function through: https://github.com/luin/ioredis

Function and params Details:

  1. connect to the redis
//set up your redis config, port, host, db, password, name, if you do not set up config, it will set default config 
connect: function ({config, port, host, db, password, name}){}
//for example
peaRedis.connect({
    port: 6379,
    host: '127.0.0.1',
    db: 'test',
    password: 'test',
    name: 'test'
})
  1. set object to the redis
//this only support object type
set: async function () {}
  1. get value from redis
//this only support String type
get: async function (key) {}
  1. hash set object to redis
//this only support object type
hset: async function (cacheName, key, value) {}
  1. get object from redis
hget: async function (cacheName, key) {}
  1. set string type to redis
//this only support string type
setValue: async function (key, value) {}
  1. get value from redis
getValue: async function (key) {}
  1. hash set string type to redis
//this only support string type
hsetValue: async function (cacheName, key, value) {}
  1. hash get value from redis
hgetValue: async function (cacheName, key) {}
  1. hash delete value from redis
hgetValue: async function (cacheName, key) {}
  1. delete value from redis
del: async function (key) {}
  1. get ioredis object
getRedis: () => {}

Join in!

I'm happy to receive bug reports, fixes, documentation enhancements, and any other improvements.

And since I'm not a native English speaker, if you find any grammar mistakes in the documentation, please also let me know. :)

Contributors

License

MIT

0.0.16

6 years ago

0.0.15

6 years ago

0.0.1

6 years ago