An open API service indexing awesome lists of open source software.

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

🌿

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*/
)
}
```