use of org.infinispan.container.entries.metadata.MetadataMortalCacheEntry in project infinispan by infinispan.
the class InternalEntryFactoryImpl method create.
@Override
public InternalCacheEntry create(Object key, Object value, Metadata metadata) {
long lifespan = metadata != null ? metadata.lifespan() : -1;
long maxIdle = metadata != null ? metadata.maxIdle() : -1;
if (!isStoreMetadata(metadata, null)) {
if (lifespan < 0 && maxIdle < 0)
return new ImmortalCacheEntry(key, value);
if (lifespan > -1 && maxIdle < 0)
return new MortalCacheEntry(key, value, lifespan, timeService.wallClockTime());
if (lifespan < 0 && maxIdle > -1)
return new TransientCacheEntry(key, value, maxIdle, timeService.wallClockTime());
return new TransientMortalCacheEntry(key, value, maxIdle, lifespan, timeService.wallClockTime());
} else {
if (lifespan < 0 && maxIdle < 0)
return new MetadataImmortalCacheEntry(key, value, metadata);
if (lifespan > -1 && maxIdle < 0)
return new MetadataMortalCacheEntry(key, value, metadata, timeService.wallClockTime());
if (lifespan < 0 && maxIdle > -1)
return new MetadataTransientCacheEntry(key, value, metadata, timeService.wallClockTime());
return new MetadataTransientMortalCacheEntry(key, value, metadata, timeService.wallClockTime());
}
}
use of org.infinispan.container.entries.metadata.MetadataMortalCacheEntry in project infinispan by infinispan.
the class InternalEntryFactoryImpl method create.
@Override
public // TODO: Do we need this???
InternalCacheEntry create(Object key, Object value, Metadata metadata, long lifespan, long maxIdle) {
if (!isStoreMetadata(metadata, null)) {
if (lifespan < 0 && maxIdle < 0)
return new ImmortalCacheEntry(key, value);
if (lifespan > -1 && maxIdle < 0)
return new MortalCacheEntry(key, value, lifespan, timeService.wallClockTime());
if (lifespan < 0 && maxIdle > -1)
return new TransientCacheEntry(key, value, maxIdle, timeService.wallClockTime());
return new TransientMortalCacheEntry(key, value, maxIdle, lifespan, timeService.wallClockTime());
} else {
// Metadata to store, take lifespan and maxIdle settings from it
long metaLifespan = metadata.lifespan();
long metaMaxIdle = metadata.maxIdle();
if (metaLifespan < 0 && metaMaxIdle < 0)
return new MetadataImmortalCacheEntry(key, value, metadata);
if (metaLifespan > -1 && metaMaxIdle < 0)
return new MetadataMortalCacheEntry(key, value, metadata, timeService.wallClockTime());
if (metaLifespan < 0 && metaMaxIdle > -1)
return new MetadataTransientCacheEntry(key, value, metadata, timeService.wallClockTime());
return new MetadataTransientMortalCacheEntry(key, value, metadata, timeService.wallClockTime());
}
}
use of org.infinispan.container.entries.metadata.MetadataMortalCacheEntry in project infinispan by infinispan.
the class CacheEntrySizeCalculator method calculateSize.
@Override
public long calculateSize(K key, InternalCacheEntry<K, V> ice) {
// This will be non zero when use expiration, but don't want to store the metadata
long noMetadataSize = 0;
boolean metadataAware;
// ImmortalCacheEntry so it has to come before
if (ice instanceof MetadataImmortalCacheEntry) {
metadataAware = true;
} else if (ice instanceof ImmortalCacheEntry) {
metadataAware = false;
} else if (ice instanceof MortalCacheEntry) {
noMetadataSize += 16;
metadataAware = false;
} else if (ice instanceof TransientCacheEntry) {
noMetadataSize += 16;
metadataAware = false;
} else if (ice instanceof TransientMortalCacheEntry) {
noMetadataSize += 32;
metadataAware = false;
} else if (ice instanceof MetadataMortalCacheEntry) {
metadataAware = true;
} else if (ice instanceof MetadataTransientCacheEntry) {
metadataAware = true;
} else {
metadataAware = ice instanceof MetadataTransientMortalCacheEntry;
}
Metadata metadata;
if (metadataAware) {
metadata = ice.getMetadata();
// We don't support other metadata types currently
if (!(metadata instanceof EmbeddedMetadata)) {
metadata = null;
}
} else {
metadata = null;
}
long keyValueMetadataSize = calculateSize(key, ice.getValue(), metadata, ice.getInternalMetadata());
return keyValueMetadataSize + noMetadataSize;
}
use of org.infinispan.container.entries.metadata.MetadataMortalCacheEntry in project infinispan by infinispan.
the class MetadataMortalCacheEntryExternalizer method readObject.
@Override
public MetadataMortalCacheEntry readObject(ObjectInput input) throws IOException, ClassNotFoundException {
Object key = input.readObject();
Object value = input.readObject();
Metadata metadata = (Metadata) input.readObject();
long created = UnsignedNumeric.readUnsignedLong(input);
return new MetadataMortalCacheEntry(key, value, metadata, created);
}
Aggregations