Skip to content

Commit 6b14826

Browse files
Clarify Near Cache null values behaviour [CTT-833] [5.6.z] (#2094)
Adds documentation about the caching of null values for Near Cache. Fixes https://hazelcast.atlassian.net/browse/CTT-833
1 parent ca8dfb7 commit 6b14826

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/modules/cluster-performance/pages/near-cache.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,18 @@ If it is expired, it is evicted and `null` is returned as the value to the calle
563563
Note that `max-idle-seconds` and `time-to-live-seconds` are configured under the `near-cache` configuration block, as seen in the above
564564
<<near-cache-configuration-examples, configuration examples>>.
565565

566+
== Caching of null values
567+
568+
When you call `get()` on a map with Near Cache enabled and the requested key does not exist in the underlying data structure, the Near Cache stores the `null` result.
569+
This means that subsequent `get()` calls for the same non-existent key are served directly from the Near Cache without requiring a network round-trip to the cluster.
570+
571+
This behavior provides a performance benefit when your application frequently checks for keys that may not exist, as it avoids repeated server lookups.
572+
573+
The cached `null` value is subject to the same expiration and invalidation rules as any other Near Cache entry:
574+
575+
* It expires based on `max-idle-seconds` and `time-to-live-seconds` configuration.
576+
* It is invalidated when an entry with that key is added to the underlying data structure.
577+
566578
== Near Cache Invalidation
567579

568580
Invalidation is the process of removing an entry from the Near Cache when its value is updated or

0 commit comments

Comments
 (0)