当前位置: 首页>>代码示例>>Java>>正文


Java Element.setTimeToLive方法代码示例

本文整理汇总了Java中net.sf.ehcache.Element.setTimeToLive方法的典型用法代码示例。如果您正苦于以下问题:Java Element.setTimeToLive方法的具体用法?Java Element.setTimeToLive怎么用?Java Element.setTimeToLive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.ehcache.Element的用法示例。


在下文中一共展示了Element.setTimeToLive方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addTicket

import net.sf.ehcache.Element; //导入方法依赖的package包/类
@Override
public void addTicket(final Ticket ticketToAdd) {
    final Ticket ticket = encodeTicket(ticketToAdd);
    final Element element = new Element(ticket.getId(), ticket);
    
    int idleValue = ticketToAdd.getExpirationPolicy().getTimeToIdle().intValue();
    if (idleValue <= 0) {
        idleValue = ticketToAdd.getExpirationPolicy().getTimeToLive().intValue();
    }
    if (idleValue <= 0) {
        idleValue = Integer.MAX_VALUE;
    }
    element.setTimeToIdle(idleValue);

    int aliveValue = ticketToAdd.getExpirationPolicy().getTimeToLive().intValue();
    if (aliveValue <= 0) {
        aliveValue = Integer.MAX_VALUE;
    }
    element.setTimeToLive(aliveValue);

    LOGGER.debug("Adding ticket [{}] to the cache [{}] to live [{}] seconds and stay idle for [{}] seconds",
            ticket.getId(), this.ehcacheTicketsCache.getName(), aliveValue, idleValue);
    this.ehcacheTicketsCache.put(element);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:25,代码来源:EhCacheTicketRegistry.java

示例2: put

import net.sf.ehcache.Element; //导入方法依赖的package包/类
@Override
public void put(String cacheName, Object key, Object value, int liveSeconds) {
    if (liveSeconds <= 0) {
        put(cacheName, key, value);
        return;
    }
    Element element = new Element(key, value);
    element.setTimeToLive(liveSeconds);
    getOrAddCache(cacheName).put(element);
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:11,代码来源:JbootEhcacheImpl.java

示例3: setTtl

import net.sf.ehcache.Element; //导入方法依赖的package包/类
@Override
public void setTtl(String cacheName, Object key, int seconds) {
    Element element = getOrAddCache(cacheName).get(key);
    if (element == null) {
        return;
    }

    element.setTimeToLive(seconds);
    getOrAddCache(cacheName).put(element);
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:11,代码来源:JbootEhcacheImpl.java

示例4: add

import net.sf.ehcache.Element; //导入方法依赖的package包/类
@Override
public void add(String key, Object value, int expires, String group) {

    net.sf.ehcache.Cache cacher = cacher(group);

    if (cacher != null) {

        Element element = new Element(key, value);
        element.setTimeToLive(expires);
        cacher.put(element);
    }
}
 
开发者ID:thundernet8,项目名称:Razor,代码行数:13,代码来源:Ehcache.java

示例5: create

import net.sf.ehcache.Element; //导入方法依赖的package包/类
public StoreEntry create(Key key, int timeToLive) {
    StoreEntryImpl result = new StoreEntryImpl(timeToLive);
    Element element = new Element(key, result);
    element.setTimeToLive(timeToLive);
    cache.put(element);
    return result;
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:8,代码来源:EhcacheTokenStore.java

示例6: incr

import net.sf.ehcache.Element; //导入方法依赖的package包/类
@Override
public synchronized long incr(String key, String group, int by) {

    net.sf.ehcache.Cache cacher = cacher(group);

    if (cacher != null) {

        Element element = cacher.get(key);

        if (element == null) {

            return -1;
        }

        long newValue = ((Number)element.getObjectValue()).longValue() + by;
        Element newEle = new Element(key, newValue);
        newEle.setTimeToLive(element.getTimeToLive());

        cacher.put(newEle);

        return newValue;
    }

    return -1;
}
 
开发者ID:thundernet8,项目名称:Razor,代码行数:26,代码来源:Ehcache.java

示例7: decr

import net.sf.ehcache.Element; //导入方法依赖的package包/类
@Override
public synchronized long decr(String key, String group, int by) {

    net.sf.ehcache.Cache cacher = cacher(group);

    if (cacher != null) {

        Element element = cacher.get(key);

        if (element == null) {

            return -1;
        }

        long newValue = ((Number)element.getObjectValue()).longValue() - by;
        Element newEle = new Element(key, newValue);
        newEle.setTimeToLive(element.getTimeToLive());

        cacher.put(newEle);

        return newValue;
    }

    return -1;
}
 
开发者ID:thundernet8,项目名称:Razor,代码行数:26,代码来源:Ehcache.java


注:本文中的net.sf.ehcache.Element.setTimeToLive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。