Skip to content

Commit 74abf0b

Browse files
committed
Add putOnRead method implementation
1 parent 7311858 commit 74abf0b

File tree

1 file changed

+18
-0
lines changed
  • core/javax.cache/src/main/java/org/wso2/carbon/caching/impl

1 file changed

+18
-0
lines changed

core/javax.cache/src/main/java/org/wso2/carbon/caching/impl/CacheImpl.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,24 @@ public void put(K key, V value) {
400400
}
401401
}
402402

403+
@Override
404+
public void putOnRead(K key, V value) {
405+
406+
Util.checkAccess(ownerTenantDomain, ownerTenantId);
407+
checkStatusStarted();
408+
lastAccessed = System.currentTimeMillis();
409+
CacheEntry entry = localCache.get(key);
410+
V oldValue = entry != null ? (V) entry.getValue() : null;
411+
if (oldValue == null) {
412+
internalPut(key, value);
413+
notifyCacheEntryCreated(key, value);
414+
} else {
415+
if (log.isDebugEnabled()) {
416+
log.debug("Cache already populated on read. Key: " + key + ", Existing value: " + oldValue);
417+
}
418+
}
419+
}
420+
403421
@Override
404422
public void putIfNoDuplicate(K key, V value) {
405423

0 commit comments

Comments
 (0)