protected boolean skipSharedStores(InvocationContext ctx, Object key, FlagAffectedCommand command) {
return !ctx.isOriginLocal() || command.hasFlag(Flag.SKIP_SHARED_CACHE_STORE);
}
InternalCacheValue getStoredValue(Object key, InvocationContext ctx) {
CacheEntry entry = ctx.lookupEntry(key);
if (entry instanceof InternalCacheEntry) {
return ((InternalCacheEntry) entry).toInternalCacheValue();
} else {
if (ctx.isInTxScope()) {
EntryVersionsMap updatedVersions =
((TxInvocationContext) ctx).getCacheTransaction().getUpdatedEntryVersions();
if (updatedVersions != null) {
EntryVersion version = updatedVersions.get(entry.getKey());
if (version != null) {
Metadata metadata = entry.getMetadata();
if (metadata == null) {
// If no metadata passed, assumed embedded metadata
metadata = new EmbeddedMetadata.Builder()
.lifespan(entry.getLifespan()).maxIdle(entry.getMaxIdle())
.version(version).build();
return entryFactory.create(entry.getKey(), entry.getValue(), metadata).toInternalCacheValue();
} else {
metadata = metadata.builder().version(version).build();
return entryFactory.create(entry.getKey(), entry.getValue(), metadata).toInternalCacheValue();
}
}
}
}