2.1.1 • Published 8 months ago

@sebspark/promise-cache v2.1.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
8 months ago

@sebspark/promise-cache

A simple caching wrapper for promises.

/*
 * Pseudocode example.
 */
import { PromiseCache } from '@sebspark/promise-cache'

// Instantiate the cache with a TTL.
const cache = new PromiseCache<number>(60, true, true) // 1 minute cache TTL / is case sensitive / use local storage

const redisCache = new PromiseCache<number>(60, false, false) // 1 minute cache TTL / is not case sensitive / use redis storage

// Use the cache wrapper for a database query to relieve the database.
const query = 'SELECT username FROM users ORDER BY created DESC LIMIT 1'
const newestUser = await cache.wrap('newestUser', () => database.query(query))

// Use the cache wrapper for a database query to relieve the database.
const query = 'SELECT username FROM users ORDER BY created DESC LIMIT 1'
const newestUser = await redisCache.wrap('newestUserRedis', () => database.query(query))
2.1.1

8 months ago

2.1.0

8 months ago

2.0.5

10 months ago

2.0.7

10 months ago

2.0.6

10 months ago

2.0.9

10 months ago

2.0.10

10 months ago

2.0.8

10 months ago

2.0.3

10 months ago

2.0.2

10 months ago

2.0.4

10 months ago

2.0.1

10 months ago

1.4.0

10 months ago

2.0.0

10 months ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.3.1

11 months ago

1.2.2

1 year ago

1.2.1

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago