docs updated
parent
e1de754031
commit
8f365d3f08
@ -0,0 +1,45 @@
|
||||
##Native implementation
|
||||
|
||||
Client Side caching is implemented using client tracking listener through `RESP3` protocol available in Redis or Valkey.
|
||||
|
||||
It's used to speed up read operations and avoid network roundtrips. It caches Map entries on Redisson side and executes read operations up to **45x faster** in comparison with common implementation.
|
||||
|
||||
Requires [protocol](configuration.md) setting value set to `RESP3`.
|
||||
|
||||
Available for [RBucket](data-and-services/objects.md/#object-holder), [RStream](data-and-services/objects.md/#stream), [RSet](data-and-services/objects.md/#set), [RMap](data-and-services/objects.md/#map), [RScoredSortedSet](data-and-services/collections.md/#scoredsortedset), [RList](data-and-services/collections.md/#list), [RQueue](data-and-services/collections.md/#queue), [RDeque](data-and-services/collections.md/#deque), [RBlockingQueue](data-and-services/collections.md/#blocking-queue), [RBlockingDeque](data-and-services/collections.md/#blocking-deque), [RDelayedQueue](data-and-services/collections.md/#delayed-queue) objects.
|
||||
|
||||
!!! note
|
||||
Client side caching feature invalidates whole Map per entry change which is ineffective.
|
||||
**Use [Advanced implementation](#advanced-implementation) instead which implements invalidation per entry.**
|
||||
|
||||
RClientSideCaching object is stateful and each instance creates own cache.
|
||||
|
||||
Code usage example:
|
||||
```java
|
||||
RClientSideCaching csc = redisson.getClientSideCaching(ClientSideCachingOptions.defaults());
|
||||
|
||||
RBucket<String> b = redisson.getBucket("test");
|
||||
|
||||
// data requested and change is now tracked
|
||||
b.get();
|
||||
|
||||
// ...
|
||||
|
||||
// call destroy() method if object and all related objects aren't used anymore
|
||||
csc.destroy();
|
||||
```
|
||||
|
||||
## Advanced implementation
|
||||
|
||||
Client side caching listener is effective only on a per-object basis. Unfortunately, this is not sufficient for structures like `Map` or `Hash`. Because the cache invalidation message doesn't contain any information about the invalidated Map field and only includes the Map name, it's impossible to evict a specific entry. As a result, only clearing the entire cache can help keep the client cache up to date.
|
||||
|
||||
To address this issue Redisson provides own client cache aka `local cache` implementations for the structures below:
|
||||
|
||||
* [Map](data-and-services/collections.md/#eviction-local-cache-and-data-partitioning)
|
||||
* [JSON Store](data-and-services/collections.md/#local-cache)
|
||||
* [JCache](cache-api-implementations.md/#local-cache-and-data-partitioning)
|
||||
* [Spring cache](cache-api-implementations.md/#eviction-local-cache-and-data-partitioning)
|
||||
* [Hibernate cache](cache-api-implementations.md/#eviction-local-cache-and-data-partitioning_1)
|
||||
* [MyBatis cache](cache-api-implementations.md/#eviction-local-cache-and-data-partitioning_2)
|
||||
* [Quarkus cache](cache-api-implementations.md/#eviction-local-cache-and-data-partitioning_3)
|
||||
* [Micronaut cache](cache-api-implementations.md/#eviction-local-cache-and-data-partitioning_4)
|
@ -1,37 +0,0 @@
|
||||
Client tracking listener is invoked when an invalidation message is received if the data previously requested has been changed. Next listener invocation will be made only if a new data request has been made and another change has occurred since then.
|
||||
|
||||
Available for [RBucket](data-and-services/objects.md/#object-holder), [RStream](data-and-services/objects.md/#stream), [RSet](data-and-services/objects.md/#set), [RMap](data-and-services/objects.md/#map), [RScoredSortedSet](data-and-services/collections.md/#scoredsortedset), [RList](data-and-services/collections.md/#list), [RQueue](data-and-services/collections.md/#queue), [RDeque](data-and-services/collections.md/#deque), [RBlockingQueue](data-and-services/collections.md/#blocking-queue), [RBlockingDeque](data-and-services/collections.md/#blocking-deque), [RDelayedQueue](data-and-services/collections.md/#delayed-queue), [RRingBuffer](data-and-services/collections.md/#ring-buffer) objects.
|
||||
|
||||
Requires [protocol](configuration.md) setting value set to `RESP3`.
|
||||
|
||||
Code usage example.
|
||||
```java
|
||||
RBucket<String> b = redisson.getBucket("test");
|
||||
int listenerId = b.addListener(new TrackingListener() {
|
||||
@Override
|
||||
public void onChange(String name) {
|
||||
// ...
|
||||
}
|
||||
});
|
||||
|
||||
// data requested and change is now tracked
|
||||
b.get();
|
||||
|
||||
// ...
|
||||
|
||||
// stop tracking
|
||||
b.removeListener(listenerId);
|
||||
```
|
||||
|
||||
**Flush listener**
|
||||
|
||||
Flush listener is executed on flushall/flushdb commands execution.
|
||||
|
||||
```java
|
||||
redisson.getKeys().addListener(new FlushListener() {
|
||||
@Override
|
||||
public void onFlush(InetSocketAddress address) {
|
||||
// ...
|
||||
}
|
||||
});
|
||||
```
|
Loading…
Reference in New Issue