Skip to content

0.12.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 25 Jun 06:37
· 85 commits to refs/heads/main since this release

Major Changes

There are a number of breaking changes in this release of Cache Tower. For the most part, these APIs will be marked as "obsolete" and should still behave as they did previously however it is important to recognise the changes that have occurred to understand the breadth of incompatibility.

Support for Custom Serializers (#172, #205)

Rather than restricting cache layers to specific serializers, you can now supply custom serializers to cache layers that require it. Officially, Cache Tower will support 3 serializers: Newtonsoft.Json, System.Text.Json and Protobuf (via protobuf-net).

  • RedisCacheLayer currently takes a dependency on CacheTower.Serializers.Protobuf for backwards compatibility for 0.12.0 and will be changed in a future release. There is a new constructor that ICacheSerializer allowing you to specify any serializer you want. The transitive dependency on CacheTower.Serializers.Protobuf will be removed in a future version.
  • JsonFileCacheLayer and ProtobufFileCacheLayer are now obsolete, instead use FileCacheLayer and specify an ICacheSerializer to use.

Additional changes to note:

  • File caching no longer specifies file extensions as they are redundant when serializers define the format. This means existing file caches will be empty after upgrading.
  • JsonFileCacheLayer used to specifically serialize your data wrapped in its own JSON object (eg. {"value": _ }) which it no longer does. Due to the file extension change, this shouldn't cause a problem as your cache will be empty. Through additional unit tests, this doesn't seem to cause a problem however if you hit an issue where it does, please raise an issue.

File Caching Changes (#203, #172)

One problem that has been raised a few times are issues around the manifest files for caching. The manifest was only writing down to the file system when the application gracefully exited. Manifests now save automatically in the background and the interval is controllable via options on the FileCacheLayer.

Additionally, there were two other fixes:

  • Prevent exceptions when attempting to read a file that doesn't exist (when detected now, the entry is removed from the manifest and treated like a cache miss)
  • Changes to the FileMode access to force truncation of data when serializing (this may have been causing specific types of cache entry corruption)

Fluent Dependency Injection Building (#204)

The fluent dependency injection process simplifies configuring Cache Tower and will be recommended method going forward. There are some minor API breaking changes when you upgrade, even if you don't use the fluent API around how certain cache layers and extensions are configured.

There are some underlying changes to how the RedisRemoteEvictionExtension works - you no longer can specify which cache layers to evict from. Cache layers are now decorated with ILocalCacheLayer and IDistributedCacheLayer which the extension uses to identify what cache layers it will evict from. Specifically, no distributed cache layer will be evicted from by the extension.

Changes to RedisLockExtension have occurred around how you specify certain options, specifically around specifying a LockCheckStrategy to choose between a pub/sub or spin lock strategy.