Giter Site home page Giter Site logo

think-redis-adapter's Introduction

think-redis

Build Status Coverage Status npm

Install

npm install think-redis

How to Use

default options

You can find all the config options at https://github.com/luin/ioredis/blob/master/lib/redis.js

const defaultConfig = {
  port: 6379,          // Redis port
  host: '127.0.0.1',   // Redis host
  password: '',
};

usage

import Redis from '../index';

let redisInst = new Redis(config);

// set key
let s1 = await redisInst.set('name2', 'lushijie'); // never expire
let s2 = await redisInst.set('name3', 'lushijie', 3000); // milliseconds
let s3 = await redisInst.set('name4', 'lushijie', 'EX', 5); //seconds
let s4 = await redisInst.set('name5', 'lushijie', 'PX', 10000); //milliseconds

// get key's value
let g1 = await redisInst.get('name2');

// delete key
let d1 = await redisInst.delete(key);

// add event listener, supported events see at https://github.com/luin/ioredis
redisInst.on('connect', function() {
  // todo
});

// increase 1, if key not exist, set key's value eq 0 and then increase 1
await redisInst.increase(key);

// decrease 1, if key not exist, set key's value eq 0 then decrease 1
await redisInst.decrease(key);

think-redis-adapter's People

Contributors

lushijie avatar lambdaxs avatar welefen avatar lizheming avatar huangxiaolu avatar

Watchers

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.