https://github.com/extra-memoize/memory-cache
🌿
https://github.com/extra-memoize/memory-cache
browser esm library nodejs npm-package typescript
Last synced: 10 months ago
JSON representation
🌿
- Host: GitHub
- URL: https://github.com/extra-memoize/memory-cache
- Owner: extra-memoize
- License: mit
- Created: 2022-04-08T08:27:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-07-04T06:59:26.000Z (about 1 year ago)
- Last Synced: 2025-08-27T07:44:10.908Z (11 months ago)
- Topics: browser, esm, library, nodejs, npm-package, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@extra-memoize/memory-cache
- Size: 1.13 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @extra-memoize/memory-cache
## Install
```sh
npm install --save @extra-memoize/memory-cache
# or
yarn add @extra-memoize/memory-cache
```
## API
### Cache
```ts
class Cache implements ICache {
clear(): void
}
```
### LRUCache
```ts
class LRUCache implements ICache {
constructor(limit: number)
delete(key: string): void
clear(): void
}
```
The classic LRU cache.
### ExpirableCache
```ts
class ExpirableCache implements ICache {
constructor(timeToLive: number /*ms*/)
clear(): void
}
```
The classisc expirable cache.
#### ExpirableCacheWithStaleWhileRevalidate
```ts
class ExpirableCacheWithStaleWhileRevalidate implements IStaleWhileRevalidateCache {
constructor(timeToLive: number /*ms*/, staleWhileRevalidate: number /*ms*/)
}
```
#### ExpirableCacheWithStaleIfError
```ts
class ExpirableCacheWithStaleIfError implements IStaleIfErrorCache {
constructor(timeToLive: number /*ms*/, staleIfError: number /*ms*/)
}
```
#### ExpirableCacheWithStaleWhileRevalidateAndStaleIfError
```ts
class ExpirableCacheWithStaleWhileRevalidateAndStaleIfError implements IStaleWhileRevalidateAndStaleIfErrorCache {
constructor(
timeToLive: number /*ms*/
, staleWhileRevalidate: number /*ms*/
, staleIfError: number /*ms*/
)
}
```
### TLRUCache
```ts
class TLRUCache implements ICache {
constructor(limit: number, timeToLive: number /*ms*/)
clear(): void
}
```
The classic TLRU cache.
#### TLRUCacheWithStaleWhileRevalidate
```ts
class TLRUCacheWithStaleWhileRevalidate implements IStaleWhileRevalidateCache {
constructor(limit: number, timeToLive: number /*ms*/, staleWhileRevalidate: number /*ms*/)
}
```
#### TLRUCacheWithStaleIfError
```ts
class TLRUCacheWithStaleIfError implements IStaleIfErrorCache {
constructor(limit: number, timeToLive: number /*ms*/, staleIfError: number /*ms*/)
}
```
#### TLRUCacheWithStaleWhileRevalidateAndStaleIfError
```ts
class TLRUCacheWithStaleWhileRevalidateAndStaleIfError implements IStaleWhileRevalidateAndStaleIfErrorCache {
constructor(
limit: number
, timeToLive: number /*ms*/
, staleWhileRevalidate: number /*ms*/
, staleIfError: number /*ms*/
)
}
```