项目作者: blakeembrey

项目描述 :
Simple decorator for caching getters on first access
高级语言: TypeScript
项目地址: git://github.com/blakeembrey/decorator-cache-getter.git
创建时间: 2019-01-21T21:53:26Z
项目社区:https://github.com/blakeembrey/decorator-cache-getter

开源协议:MIT License

下载


Decorator Cache Getter

NPM version
NPM downloads
Build status
Test coverage

Simple decorator for caching getters on first access.

Installation

  1. npm install decorator-cache-getter --save

Usage

  1. import { cache } from "decorator-cache-getter";
  2. class User {
  3. @cache
  4. get friends() {
  5. return sql("SELECT * FROM users WHERE ...")
  6. }
  7. }
  8. const user = new User()
  9. const friends = await user.friends;

License

MIT