@express.ts/cache
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@express.ts/cache

A simple in-memory cache for @express.ts

Installation

npm install @express.ts/cache --save

Usage

Test.ts

import { Cache } from "@express.ts/cache";

export class Test {

  protected value = Date.now();

  getExecutionTime () {
    return Date.now() - this.value;
  }

  @Cache(1000) // 1s
  getExecutionTimeWithCache () {
    return Date.now() - this.value;
  }

}

App.ts

import { Test } from "./Test";

const testInstance = new Test();

console.log([ // [ 4, 4 ]
  testInstance.getExecutionTime(),
  testInstance.getExecutionTimeWithCache()
]);

console.log([ // [ 24, 4 ]
  testInstance.getExecutionTime(),
  testInstance.getExecutionTimeWithCache()
]);

setTimeout(() => {
  console.log([ // [ 1038, 1038 ]
    testInstance.getExecutionTime(),
    testInstance.getExecutionTimeWithCache()
  ]);
}, 1001)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i @express.ts/cache

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

133 kB

Total Files

16

Last publish

Collaborators

  • aboulmane