Skip to content

Releases: angelnikolov/ts-cacheable

1.0.10

20 Oct 18:40
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 1.0.7...1.0.10

1.0.7

28 Sep 21:43
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 1.0.6...1.0.7

1.0.6

16 Nov 20:17
Compare
Choose a tag to compare

Added ^7.4.0 to the rxjs peer dependencies and updated typecsript to '^4.3.2'.

What's Changed

New Contributors

Full Changelog: 1.0.5...1.0.6

1.0.5

23 Apr 18:07
Compare
Choose a tag to compare

Exposed an additional ctx (Context) parameter for all storage strategy methods. For ex. - abstract add(entity: ICachePair<any>, cacheKey: string, ctx?: any): void;
With that, you get access to the instance which called the decorated method. This is useful for stateful operations or properly caching when using multiple instances of the same class as described here.

1.0.4

06 Mar 22:37
56160de
Compare
Choose a tag to compare

Deprecated updateAtIndex and removeAtIndex in IStorageStrategy and IStorageStrategy.
Use update and remove.
You will also find that the signature of remove is now remove?(index: number, entity: ICachePair<any>, cacheKey: string): void;
The only difference here is that the removeable entity is passed to the callback so it can be used for finding the correct object to remove in the selected storage.

1.0.3

09 Feb 21:53
5561ed9
Compare
Choose a tag to compare

Added a cacheModifier parameter to the Cacheable configuration.
It can be used as a way to access the cached data for the decorated method and modify it.

You can get access to the cached data and change it by providing a cacheModifier subject to your decorator like this:

const cacheModifier = new Subject<any>();
@Cacheable({
  cacheModifier
})
getMutableData(parameter: string) {
  return this.getData(parameter);
}

Then, say you want to change the cached data somewhere in your code.
You can emit a callback through the cacheModifier subject, which will be called upon all your cached data for this decorator, by:

cacheModifier.next((data: any[]) => {
  data.find(p => p.parameters[0] === 'test').response.payload = 'test_modified';
  return data;
});

What happens here is that we look for the cache under the 'test' parameter here and modify it to a different string.
data is all the caches for this method so you can change it in whatever way you want.

Now, if this method is called with the same parameter as before, it will still return cached data, but this time modified.
You can also delete and add more data to the cache.

1.0.1

10 Nov 13:30
Compare
Choose a tag to compare

Library has been renamed to ts-cacheable
DOMStorageStrategy is now deprecated. Use LocalStorageStrategy instead.

1.4.0

22 Jan 17:27
Compare
Choose a tag to compare

Description

We migrated the project structure to es modules. Depending on what environment you build the project with (Node, web) you will get the correct assets imported.

Why

The default module format we used to support was CommonJS, which was non tree-shakeable. That resulted in the library adding quite a bit of code to webpack bundles (mainly due to the whole rxjs library being included).

Breaking changes

DOMStorageStrategy is now imported from ngx-cacheable directly like:

import { DOMStorageStrategy } from 'ngx-cacheable'

1.3.1

08 Dec 09:25
Compare
Choose a tag to compare

Based on the discussion in #57, we figured that it could be nice to extend the global cache config to allow for options like:
maxAge,
maxCacheCount
and slidingExpiration

1.3.0

29 Oct 17:21
Compare
Choose a tag to compare

Introduced a custom cacheHasher configuration which allows to pass a custom hash function which will be used to calculate the cacheKey for a method call, based on the passed parameters.
The default cache hasher is still using JSON.parse(JSON.stringify(parameters)) but the parameters passed to the original function will no longer be mutated.
So now you can pass your own function to produce your cache key out of parameters and also pass a custom resolver, which will try to find the cache by those keys.