koatty_cacheable
TypeScript icon, indicating that this package has built-in type declarations

1.4.3 • Public • Published

koatty_cacheable

Cacheable for koatty.

Koatty框架的 CacheAble, Cacheable, CacheEvict 支持库

Usage

db.ts in koatty project:

export default {
    ...

    "CacheStore": {
        type: "memory", // redis or memory, memory is default
        // key_prefix: "koatty",
        // host: '127.0.0.1',
        // port: 6379,
        // name: "",
        // username: "",
        // password: "",
        // db: 0,
        // timeout: 30,
        // pool_size: 10,
        // conn_timeout: 30
    },

    ...
};

used in service:

import { CacheAble, CacheEvict, GetCacheStore } from "koatty_cacheable";

export class TestService {

    @CacheAble("testCache") // auto cached
    getTest(){
        //todo
    }

    @CacheEvict("testCache") // auto clear cache
    setTest(){
        //todo
    }

    test(){
        const store = GetCacheStore(this.app);
        store.set(key, value);
    }
}

Package Sidebar

Install

npm i koatty_cacheable

Weekly Downloads

5

Version

1.4.3

License

BSD-3-Clause

Unpacked Size

33.7 kB

Total Files

12

Last publish

Collaborators

  • richenlin