/** * Create a new write operation for a particular element and creation time * * @param element the element to write * @param creationTime the creation time of the operation */ public WriteOperation(Element element, long creationTime) { this.element = new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); this.creationTime = creationTime; }
private CacheEntry duplicateCacheEntryElement(CacheEntry entry) { if (null == entry.getElement()) { return entry; } else { Element element = entry.getElement(); return new CacheEntry(entry.getKey(), new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime())); } }
public ElementData(final Element element) { this.value = element.getValue(); this.version = element.getVersion(); this.creationTime = element.getCreationTime(); this.lastAccessTime = element.getLastAccessTime(); this.hitCount = element.getHitCount(); this.cacheDefaultLifespan = element.usesCacheDefaultLifespan(); this.lastUpdateTime = element.getLastUpdateTime(); }
/** * Make a duplicate of an element but using the specified value * * @param element the element to duplicate * @param newValue the new element's value * @return the duplicated element */ public Element duplicateElementWithNewValue(final Element element, final Object newValue) { Element newElement; if (element.usesCacheDefaultLifespan()) { newElement = new Element(element.getObjectKey(), newValue, element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(), Integer.MIN_VALUE, Integer.MIN_VALUE, element.getLastUpdateTime()); } else { newElement = new Element(element.getObjectKey(), newValue, element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(), element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); } if (ElementIdHelper.hasId(element)) { ElementIdHelper.setId(newElement, ElementIdHelper.getId(element)); } return newElement; }
/** * Return the version of the element for the specified key. * * @param key The key * * @return The version of the element or <code>null</code> if the key or element is <code>null</code> */ @Override public synchronized @Nullable Long getVersion(String key) { if (key == null) return null; Element element = this._cache.get(key); if (element != null) return element.getVersion(); else return null; }
/** * Create a new write operation for a particular element and creation time * * @param element the element to write * @param creationTime the creation time of the operation */ public WriteOperation(Element element, long creationTime) { this.element = new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); this.creationTime = creationTime; }
/** * Create a new write operation for a particular element and creation time * * @param element the element to write * @param creationTime the creation time of the operation */ public WriteOperation(Element element, long creationTime) { this.element = new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); this.creationTime = creationTime; }
/** * Create a new write operation for a particular element and creation time * * @param element the element to write * @param creationTime the creation time of the operation */ public WriteOperation(Element element, long creationTime) { this.element = new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); this.creationTime = creationTime; }
private CacheEntry duplicateCacheEntryElement(CacheEntry entry) { if (null == entry.getElement()) { return entry; } else { Element element = entry.getElement(); return new CacheEntry(entry.getKey(), new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime())); } }
private CacheEntry duplicateCacheEntryElement(CacheEntry entry) { if (null == entry.getElement()) { return entry; } else { Element element = entry.getElement(); return new CacheEntry(entry.getKey(), new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime())); } }
private CacheEntry duplicateCacheEntryElement(CacheEntry entry) { if (null == entry.getElement()) { return entry; } else { Element element = entry.getElement(); return new CacheEntry(entry.getKey(), new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime())); } }
public void run(){ if (e.getVersion() == signature){ // triple check try{ V newValue = getDirectly((K)e.getObjectKey()); if (newValue == null){ cache.remove(e.getObjectKey()); }else{ cache.put(new Element((K)e.getObjectKey(), newValue)); } }catch(Exception ex){ logger.warn("Failed to update the value associated with specified key '{}' in cache '{}'", e.getObjectKey(), cache.getName(), ex); } } } });
/** * Make a duplicate of an element but using the specified value * * @param element the element to duplicate * @param newValue the new element's value * @return the duplicated element * @see net.sf.ehcache.store.compound.ReadWriteSerializationCopyStrategy#duplicateElementWithNewValue(net.sf.ehcache.Element, Object) * @since 1.4.0-beta1 */ Element duplicateElementWithNewValue(final Element element, final Object newKey, final Object newValue) { return new Element(newKey, newValue, element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(), element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); }
/** * Make a duplicate of an element but using the specified value * * @param element the element to duplicate * @param newValue the new element's value * @return the duplicated element */ public Element duplicateElementWithNewValue(final Element element, final Object newValue) { return new Element(element.getObjectKey(), newValue, element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(), element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); }
/** * Make a duplicate of an element but using the specified value * * @param element the element to duplicate * @param newValue the new element's value * @return the duplicated element * @see net.sf.ehcache.store.compound.ReadWriteSerializationCopyStrategy#duplicateElementWithNewValue(net.sf.ehcache.Element, Object) * @since 1.4.0-beta1 */ Element duplicateElementWithNewValue(final Element element, final Object newKey, final Object newValue) { return new Element(newKey, newValue, element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(), element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); }
public ElementSnapshot(Element element) { this.version = element.getVersion(); this.hitCount = element.getHitCount(); this.timeToLive = element.getTimeToLive(); this.timeToIdle = element.getTimeToIdle(); this.creationTime = element.getCreationTime(); this.lastAccessTime = element.getLastAccessTime(); this.lastUpdateTime = element.getLastUpdateTime(); }
public ElementData(final Element element) { this.value = element.getValue(); this.version = element.getVersion(); this.creationTime = element.getCreationTime(); this.lastAccessTime = element.getLastAccessTime(); this.hitCount = element.getHitCount(); this.cacheDefaultLifespan = element.usesCacheDefaultLifespan(); this.lastUpdateTime = element.getLastUpdateTime(); }
public static Element unwrapElement(Element element, ValueProcessor valueProcessor) { return element == null ? null : new Element( valueProcessor.unwrap(element.getObjectKey()), valueProcessor.unwrap(element.getObjectValue()), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(), element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); } }
/** * Make a duplicate of an element but using the specified value * * @param element the element to duplicate * @param newValue the new element's value * @return the duplicated element */ public Element duplicateElementWithNewValue(final Element element, final Object newValue) { Element newElement; if (element.usesCacheDefaultLifespan()) { newElement = new Element(element.getObjectKey(), newValue, element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(), Integer.MIN_VALUE, Integer.MIN_VALUE, element.getLastUpdateTime()); } else { newElement = new Element(element.getObjectKey(), newValue, element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(), element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); } if (ElementIdHelper.hasId(element)) { ElementIdHelper.setId(newElement, ElementIdHelper.getId(element)); } return newElement; }
/** * Make a duplicate of an element but using the specified value * * @param element the element to duplicate * @param newValue the new element's value * @return the duplicated element */ public Element duplicateElementWithNewValue(final Element element, final Object newValue) { Element newElement; if (element.usesCacheDefaultLifespan()) { newElement = new Element(element.getObjectKey(), newValue, element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(), Integer.MIN_VALUE, Integer.MIN_VALUE, element.getLastUpdateTime()); } else { newElement = new Element(element.getObjectKey(), newValue, element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(), element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime()); } if (ElementIdHelper.hasId(element)) { ElementIdHelper.setId(newElement, ElementIdHelper.getId(element)); } return newElement; }