Skip to content

Commit

Permalink
fix(cache): expose maxCacheSize prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Guerrero committed Apr 28, 2022
1 parent ef0020f commit 5a10c9e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libs/ngrx-traits/src/lib/cache/cache.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ export function cache<T>({
key,
source,
expires,
maxCacheSize,
}: {
store: Store;
key: CacheKey;
source: Observable<T>;
expires?: number;
maxCacheSize?: number;
}) {
const exp = expires ?? Infinity;
return store.select(selectCache(key)).pipe(
Expand All @@ -28,7 +30,12 @@ export function cache<T>({
: source.pipe(
tap((value) =>
store.dispatch(
CacheActions.cache({ key, date: Date.now(), value })
CacheActions.cache({
key,
date: Date.now(),
value,
maxCacheSize,
})
)
)
)
Expand Down

0 comments on commit 5a10c9e

Please sign in to comment.