This post explains different ways in which we can remove entries in a cache using JCache api. The JCache api provides the below methods 1) boolean remove(K key) –> remove an entry with key matching the method parameter 2) boolean remove(K key, V oldValue) –> removes an entry with matching key and value 3) void…… Continue reading Different ways to remove cache entry
Month: November 2016
JCache Expiry Policy Example
This post explains about JCache’s Expiry policy with an example. Cache’s Expiry policy is used to inform the caching provider when to remove an entry. The below code uses JCache’s CreatedExpiryPolicy as an example. CreatedExpiryPolicy is used to inform the cache provider to remove the entry after a specified time since the entry’s addition to…… Continue reading JCache Expiry Policy Example
Mocking abstract classes
This post explain mocking abstract classes for testing purposes. Note 1) This feature is not available in pre 1.10.12 release 2) We can mock abstract class only if it has parameter less constructor Below is the example of how we can do it. ClassA (Abstract Class) package package2; public abstract class ClassA { public abstract…… Continue reading Mocking abstract classes
Reading json data in non-streaming way (object model)
We can read a json file and create an object model of it, using the ObjectMapper’s readTree api. ObjectMapper class is responsible for parsing the json file and create appropriate java objects. It uses Jackson’s parsing feature internally for reading the json file. They are many overloaded method of readTree available in ObjectMapper. In this…… Continue reading Reading json data in non-streaming way (object model)
Replacing cache entry’s value
This post explains two ways provided by JCache api through, which we can replace the values of existing cache entry. JCache provides two apis for replacing the cache entry 1) replace(key, newValue) –> This api replaces an entry with matching key given in the method argument with newValue. It returns true when replaced else false.…… Continue reading Replacing cache entry’s value