[Tencent Cloud] 0 basic website template starting from 9 yuan! >>>
Since the launch of J2Cache, many people have hoped to provide the read-only mode of the second-level cache, which means that the application can only read data from the Redis second-level cache, and is not allowed to write any data, including when the first-level cache fails. Clear the data in the second level cache. Such developers generally use a separate process to update cache data and achieve cache synchronization within the cluster.
Considering that many developers have this demand, this updated version is hereby released to support the read-only mode of the second-level cache. The specific implementation method is relatively simple. The core code of J2Cache is not moved, but a ReadonlyRedisCacheProvider is overloaded to shield the write method of the cache.
To use read-only mode, just upgrade to version 2.3.12 and modify the configuration as follows:
j2cache.L2.provider_class = readonly-redis
And add j2cache.L2.config_section = redis to the configuration to use the existing redis configuration.
Maven:
<dependency> <groupId>net.oschina.j2cache</groupId> <artifactId>j2cache-core</artifactId> <version>2.3.12-release</version> </dependency>
After finishing work, please go to https://gitee.com/ld/J2Cache to give a Star!