BlazingCache uses the JCache (JSR107) https://jcp.org/en/jsr/detail?id=107 interface in order to provide an unified API for cache clients.
This page will describe the details of how BlazingCache implements JSR107.
In order to use the JSR107 you need an additional dependency:
<dependency> <groupId>org.blazingcache</groupId> <artifactId>blazingcache-jcache</artifactId> <version>VERSION</version> </dependency>
Using this dependency the javax.cache.Caching.getCachingProvider() will give you the BlazingCache based implementation. In case of presence of more than one implementation you have to discover available providers or instantiate directly BlazingCacheProvider.
Each CacheManager will instantiate a CacheClient and so it will handle the connectivity to the CacheServer. For each javax.cache.Cache the CacheManager will provide an abstraction on the key space and will use the name of the javax.cache.Cache as a prefix for keys.
Be sure to close the CacheManager, which in turn will shutdown the CacheClient, closing network connections and stopping all the support threads.
Closing the BlazingCacheProvider will close of the CacheManager.
Closing a javax.cache.Cache will not close the underlying CacheClient.
BlazingCache has been built to manage keys as Strings and values as byte but when using the javax.cache.Cache API you can use any java.io.Serializable class for your application.
Your keys will be converted automatically to String using the KeySerializer.
You can configure the KeySerializer using the "blazingcache.jcache.keyserializer" property when getting the CacheManager. If you are going to use String keys the default serializer will use them directly, only prepending them with the suffix.
Your values will be converted automatically to byte using the ValuesSerializer. You can configure the ValuesSerializer using the "blazingcache.jcache.valuesserializer" property when getting the CacheManager. The default is ValuesSerializer.
Every configurable artifact passed to the CacheManager.createCache will be instantiated and executed by the local JVM. You have to configure every client in the same way in order to achieve a uniform behavior for your CacheLoader, CacheWriter, Listener and ExpiryPolicy.
Actually asynchronous listeners are executed in the same thread (and so they are not really asynchronous).
When you configure Listeners or CacheLoaders or CacheWriters some times the specs require the system to access the 'previous value' and this will lead to issuing fetchs or other network-related operations.
Then you configure expiration by access every get will need a touch in order to change the expiration timestamp for the entry.
The default configuration, without such artifacts will use the best of BlazingCache and achieve the maximum performance.
A note on statistics: the "average times" are never computed and will always return 0. Other kind of statistics will be very accurate.
Warning: CAS-operations are not working properly in version 1.3.0 or below, they are only prototypes which does not enforce concurrency requirements. Same applies to EntryProcessor operations.
Since version 1.4.0 CAS semantics are working as expected
Updated less than a minute ago