1.0.1 • Published 6 years ago

think-redis2 v1.0.1

Weekly downloads
10
License
-
Repository
github
Last release
6 years ago

Redis for ThinkJS

// src/config/extend.ts
const redis = require('think-redis2');
import {think} from 'thinkjs';

module.exports = [
    redis(think.app),
];
// src/controller/index.ts
import Base from './base.js';
import {think} from 'thinkjs';

export default class extends Base {
  async setAction() {
    const redis = this.redis();
    redis.set("some", 123);
    this.body = "OK";
  }

  async getAction() {
    const redis = this.redis();
    const some = await redis.get("some");
    this.body = some; // 123
  }
}