热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

net.sf.ehcache.Element.getTimeToLive()方法的使用及代码示例

本文整理了Java中net.sf.ehcache.Element.getTimeToLive()方法的一些代码示例,展示了Element.getTimeTo

本文整理了Java中net.sf.ehcache.Element.getTimeToLive()方法的一些代码示例,展示了Element.getTimeToLive()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getTimeToLive()方法的具体详情如下:
包路径:net.sf.ehcache.Element
类名称:Element
方法名:getTimeToLive

Element.getTimeToLive介绍

暂无

代码示例

代码示例来源:origin: ninjaframework/ninja

public synchronized long incr(String key, int by) {
Element e = ehCache.get(key);
if (e == null) {
return -1;
}
long newValue = ((Number) e.getObjectValue()).longValue() + by;
Element newE = new Element(key, newValue);
newE.setTimeToLive(e.getTimeToLive());
ehCache.put(newE);
return newValue;
}

代码示例来源:origin: ninjaframework/ninja

public synchronized long decr(String key, int by) {
Element e = ehCache.get(key);
if (e == null) {
return -1;
}
long newValue = ((Number) e.getObjectValue()).longValue() - by;
Element newE = new Element(key, newValue);
newE.setTimeToLive(e.getTimeToLive());
ehCache.put(newE);
return newValue;
}

代码示例来源:origin: net.sf.ehcache/ehcache

public NonEternalElementData(final Element element) {
super(element);
timeToIdle = element.getTimeToIdle();
timeToLive = element.getTimeToLive();
}

代码示例来源:origin: net.sf.ehcache/ehcache

/**
* Returns the expiration time based on time to live. If this element also has a time to idle setting, the expiry
* time will vary depending on whether the element is accessed.
*
* @return the time to expiration
*/
public long getExpirationTime() {
if (!isLifespanSet() || isEternal()) {
return Long.MAX_VALUE;
}
long expiratiOnTime= 0;
long ttlExpiry = creationTime + TimeUtil.toMillis(getTimeToLive());
long mostRecentTime = Math.max(creationTime, lastAccessTime);
long ttiExpiry = mostRecentTime + TimeUtil.toMillis(getTimeToIdle());
if (getTimeToLive() != 0 && (getTimeToIdle() == 0 || lastAccessTime == 0)) {
expiratiOnTime= ttlExpiry;
} else if (getTimeToLive() == 0) {
expiratiOnTime= ttiExpiry;
} else {
expiratiOnTime= Math.min(ttlExpiry, ttiExpiry);
}
return expirationTime;
}

代码示例来源:origin: net.sf.ehcache/ehcache

/**
* 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;
}

代码示例来源:origin: net.sf.ehcache/ehcache

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()));
}
}

代码示例来源:origin: net.sf.ehcache/ehcache

private boolean doPutWithCustomLifespan(String portableKey, Element element) {
ElementData value = valueModeHandler.createElementData(element);
int creatiOnTimeInSecs= (int) (element.getCreationTime() / 1000);
int customTTI = element.isEternal() ? Integer.MAX_VALUE : element.getTimeToIdle();
int customTTL = element.isEternal() ? Integer.MAX_VALUE : element.getTimeToLive();
if (checkContainsKeyOnPut) {
return backend.put(portableKey, value, creationTimeInSecs, customTTI, customTTL) == null;
} else {
backend.putNoReturn(portableKey, value, creationTimeInSecs, customTTI, customTTL);
return true;
}
}

代码示例来源:origin: net.sf.ehcache/ehcache

/**
* 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;
}

代码示例来源:origin: yangfuhai/jboot

@Override
public Integer getTtl(String cacheName, Object key) {
Element element = getOrAddCache(cacheName).get(key);
return element != null ? element.getTimeToLive() : null;
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

public NonEternalElementData(final Element element) {
super(element);
timeToIdle = element.getTimeToIdle();
timeToLive = element.getTimeToLive();
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.playframework/play

@Override
public synchronized long incr(String key, int by) {
Element e = cache.get(key);
if (e == null) {
return -1;
}
long newValue = ((Number) e.getValue()).longValue() + by;
Element newE = new Element(key, newValue);
newE.setTimeToLive(e.getTimeToLive());
cache.put(newE);
return newValue;
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.playframework/play

@Override
public synchronized long decr(String key, int by) {
Element e = cache.get(key);
if (e == null) {
return -1;
}
long newValue = ((Number) e.getValue()).longValue() - by;
Element newE = new Element(key, newValue);
newE.setTimeToLive(e.getTimeToLive());
cache.put(newE);
return newValue;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
* 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;
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

/**
* 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;
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-1.7

public IdentityModeElementData(final Element element, long creationTime) {
super(element.getObjectValue(), element.getCreationTime(),
creatiOnTime== Integer.MIN_VALUE ? element.getCreationTime() : creationTime, element.getLastAccessTime(),
element.getHitCount(), element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime());
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.0

public SerializationModeElementData(final Element element) {
this(element.getObjectValue(), element.getCreationTime(),
element.getCreationTime(), element.getLastAccessTime(),
element.getHitCount(), element.usesCacheDefaultLifespan(),
element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime());
}

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

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()));
}
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

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()));
}
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

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()));
}
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
* 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());
}

推荐阅读
author-avatar
梦之舞的微薄极_922
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有