Skip to content

Commit

Permalink
Release 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Angel Nikolov committed Dec 8, 2019
1 parent dc1c2cc commit 842e955
Show file tree
Hide file tree
Showing 19 changed files with 794 additions and 431 deletions.
47 changes: 47 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,53 @@ export interface ICacheConfig {
}
```

## Global Configuration
Some of the local cache config options (passed to specific decorators) can also be used as global ones. All the local configurations will of course take precedence over the global ones.
Here are all the possible global configurations:
```ts
/**
* whether should use a sliding expiration strategy on caches
* this will reset the cache created property and keep the cache alive for @param maxAge milliseconds more
*/
slidingExpiration: boolean;
/**
* max cacheCount for different parameters
* @description maximum allowed unique caches (same parameters)
*/
maxCacheCount: number;
/**
* @description request cache resolver which will get old and new paramaters passed to and based on those
* will figure out if we need to bail out of cache or not
*/
cacheResolver: ICacheRequestResolver;
/**
* @description cache hasher which will be called to hash the parameters into a cache key
*/
cacheHasher: ICacheHasher;
/**
* @description cache decider that will figure out if the response should be cached or not, based on it
*/
shouldCacheDecider: IShouldCacheDecider;
/**
* maxAge of cache in milliseconds
* @description if time between method calls is larger - we bail out of cache
*/
maxAge: number;
/**
* @description storage strategy to be used for setting, evicting and updating cache.
*/
storageStrategy: new () => IStorageStrategy | IAsyncStorageStrategy;
/**
* @description global cache key which will be used to namespace the cache.
* for example, it will be used in the DOMStorageStrategy for now.
*/
globalCacheKey: string;
/**
* @description a custom promise implementation. For example, if you use angularjs, you might like to provide $q's promise here change detection still works properly.
*/
promiseImplementation: (() => PromiseConstructorLike) | PromiseConstructorLike;
```

## Examples
### Cache Busting
You can achieve it by decorating the cache busting method with the CacheBuster decorator. So you can have one method for fetching and caching data and another, to remove the cache. This is useful when for example you want to add an item to a list and refresh that list afterwards.
Expand Down
16 changes: 8 additions & 8 deletions dist/cacheable.decorator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cacheable.decorator.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/common/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export declare type IShouldCacheDecider = (response: any) => boolean;
export declare type ICacheable<T> = (...args: Array<any>) => T;
export { ICacheBusterConfig, ICacheConfig, ICachePair };
export declare const GlobalCacheConfig: {
maxAge?: number;
slidingExpiration?: boolean;
maxCacheCount?: number;
cacheResolver?: ICacheResolver;
cacheHasher?: ICacheHasher;
storageStrategy: new () => IStorageStrategy | IAsyncStorageStrategy;
Expand Down
2 changes: 1 addition & 1 deletion dist/common/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-cacheable",
"version": "1.3.0",
"version": "1.3.1",
"description": "Promise/Observable cache decorators",
"main": "./index.js",
"types": "./index.d.ts",
Expand Down
16 changes: 8 additions & 8 deletions dist/promise.cacheable.decorator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 842e955

Please sign in to comment.