Skip to content

flowxjs/TypeServiceRedis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@flowxjs/redis

基于TypeService的Redis缓存框架

Install

$ npm i @flowxjs/redis

Usage

import { cacheable, TypeRedis, buildCache, deleteCache } from '@flowx/redis';

const x = new TypeRedis({
  host: '129.211.10.111',
  memory: true,
});

class ABC {
  @cacheable('test:${0}:ttt:${1}', 3600)
  sum(a: number, b: number) {
    return a + b;
  }
}

const t = new ABC();

Promise.resolve(t.sum(8, 3))
.then(d => console.log('first value:', d))
.then(() => Promise.resolve(t.sum(8, 3)))
.then(d => console.log('cache value:', d))
.then(() => x.get('test:8:ttt:3'))
.then(d => console.log('redirect value:', d))
.then(() => buildCache(ABC, 'sum', 8, 3))
.then(() => t.sum(8, 3))
.then(d => console.log('build value:', d))
.then(() => deleteCache(ABC, 'sum', 8, 3))
.then(() => x.get('test:8:ttt:3'))
.then(d => console.log('delete value:', d));

output:

first value: 11
cache value: 11
redirect value: 11
build value: 11
delete value: undefined

About

redis cache for typeservice

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published