Skip to content

blakeembrey/decorator-cache-getter

Repository files navigation

Decorator Cache Getter

NPM version NPM downloads Build status Test coverage

Simple decorator for caching getters on first access.

Installation

npm install decorator-cache-getter --save

Usage

import { cache } from "decorator-cache-getter";

class User {
  @cache
  get friends() {
    return sql("SELECT * FROM users WHERE ...")
  }
}

const user = new User()
const friends = await user.friends;

License

MIT

About

Simple decorator for caching getters on first access

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published