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

1.1.8 • Public • Published

LZO: Hyperc

Caching in Node.js to optimize app performance

Sponsor Commitizen friendly TypeScript version Node.js version MIT Build Status - GitHub Actions

Installation

npm install lzo-hyperc OR yarn add lzo-hyperc

Configuration

Please input the credentials of your Redis server in the .env file.

See the example in the .env.example file.

REDIS_URL="redis://IP:PORT"
REDIS_PORT=6379
REDIS_PASSWORD="PASSWORD"

Usage

import { Hyperc } from 'lzo-hyperc';

await Hyperc.create('test', 1000); // Create a cache with a 1 second TTL

await Hyperc.set('test', 'name', 'John Doe'); // Set a value in the cache

await Hyperc.get('test', 'name'); // John Doe

setTimeout(() => {
  cache.get('test', 'name').then(console.log); // null (cache expired)
}, 1000);

API

Hyperc.create(identifier: string | number, ttl: number): Promise<boolean>

Create a cache with a TTL.

Hyperc.set<T>(identifier: string | number, key: string, value: T): Promise<boolean>

Set a value in the cache.

Hyperc.get<T>(identifier: string | number, key: string): Promise<T | null>

Get a value from the cache.

Hyperc.del(identifier: string | number, key: string): Promise<boolean>

delete a value in the cache.

Hyperc.flush(identifier: string | number): Promise<boolean>

Flush the cache by identifier.

Hyperc.flushAll(): Promise<boolean>

Flush all caches.

Backers & Sponsors

Support this project by becoming a sponsor.

License

Licensed under the MIT. See the LICENSE file for details.

Dependents (0)

Package Sidebar

Install

npm i lzo-hyperc

Weekly Downloads

1

Version

1.1.8

License

MIT

Unpacked Size

13.8 kB

Total Files

5

Last publish

Collaborators

  • guilhermesantos001