https://github.com/pangwa/ngrx-cache
https://github.com/pangwa/ngrx-cache
anuglar cache rxjs typescript
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pangwa/ngrx-cache
- Owner: pangwa
- License: mit
- Created: 2018-04-12T21:18:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-12T23:47:27.000Z (over 7 years ago)
- Last Synced: 2025-03-22T21:05:54.608Z (7 months ago)
- Topics: anuglar, cache, rxjs, typescript
- Language: TypeScript
- Size: 7.81 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ngrx-cache
[](https://www.npmjs.org/package/ngrx-cache)
[](https://travis-ci.org/pangwa/ngrx-cache)A simple in memory cache for rx obserable using typescript decorator. It could be used with angular easily.
### Table of Contents
- [Quick Start](#quick-start)
- [Configuration Options](#configuration-options)### Quick Start
`npm install --save ngrx-cache````ts
import { ngrxCache } from 'ngrx-cache'class MyService{
@ngrxCache({key: (id: number) => `c_${id}`})
public getValue(id: number) {
return Observable.from([{id,}])
}
}// getValue() result will be cached
myService.getValue(3).subscribe(..)
```
### Configuration Options
- cacheError?: boolean (default: false)Should cache the result in case any of the error or not.
By default the value will be removed from the cache if it got any error. Set cacheError to true if you want to cache errors.
- key: string | Function
The key of the cache. Could be a string or a function.
The arguments method will be feeded to it if it is a function.
- store?: CacheStore (default: global cacheStore)The cache store instance. By default the global cache store will be used.
- ttl?: numberTime to live of the key. Note: ttl is not supported by the defaultStore currently