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


Java RemovalCause.EXPIRED属性代码示例

本文整理汇总了Java中com.google.common.cache.RemovalCause.EXPIRED属性的典型用法代码示例。如果您正苦于以下问题:Java RemovalCause.EXPIRED属性的具体用法?Java RemovalCause.EXPIRED怎么用?Java RemovalCause.EXPIRED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.common.cache.RemovalCause的用法示例。


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

示例1: testCacheExpire

@Test
public void testCacheExpire() throws InterruptedException {
    int total = 10;
    final Map<String, String> expired = new HashMap<>();
    RemovalListener removalListener = new RemovalListener<String, String>() {
        @Override
        public void onRemoval(RemovalNotification<String, String> notification) {
            if(RemovalCause.EXPIRED == notification.getCause()) {
                expired.put(notification.getKey(), notification.getValue());
            }
        }
    };
    Cache<String, String> myCache = CacheBuilder.newBuilder()
            .expireAfterWrite(2, TimeUnit.MILLISECONDS)
            .removalListener(removalListener)
            .build();
    for(int i = 0; i < total; i++) {
        myCache.put("key_" + i, "val_" + i);
    }
    Thread.sleep(10);
    myCache.cleanUp();
    assertEquals(total, expired.size());
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:23,代码来源:TransactionManagerTest.java

示例2: init

public static void init() {
	RemovalListener<String, Object> removalListener = removal -> {
		if (removal.getCause() == RemovalCause.EXPIRED) {
			getModpacks();
		}
	};
	MODPACKS_CACHE = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).removalListener(removalListener).build();
	getModpacks();
	getMods();
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:10,代码来源:Curse.java

示例3: onRemoval

@Override
public void onRemoval(RemovalNotification<String, String> notification) {
    // rollback transaction on expire
    if(RemovalCause.EXPIRED == notification.getCause()) {
        rollback(notification.getKey());
    }
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:7,代码来源:TransactionManager.java

示例4: onRemoval

/**
 * Callback method for removal of items from the histories cache. Items removed from the cache need to be acked or failed
 * according to the reason they were removed
 */
@Override
public void onRemoval(RemovalNotification<CVParticle, String> notification) {
	// make sure the CVParticle object is removed from the history (even if removal was automatic!)
	history.clear(notification.getKey(), notification.getValue());
	if(notification.getCause() == RemovalCause.EXPIRED || notification.getCause() == RemovalCause.SIZE){
		// item removed automatically --> fail the tuple
		collector.fail(notification.getKey().getTuple());
	}else{
		// item removed explicitly --> ack the tuple
		collector.ack(notification.getKey().getTuple());
	}
}
 
开发者ID:sensorstorm,项目名称:StormCV,代码行数:16,代码来源:BatchInputBolt.java

示例5: onRemoval

/**
 * {@inheritDoc}
 */
@Override
public void onRemoval(final RemovalNotification<String, StratumTcpServerConnection> notification)
{
    if (notification.getCause() == RemovalCause.EXPIRED)
        StratumTcpServer.this.onConnectionTimeout(notification.getValue());
}
 
开发者ID:GuyPaddock,项目名称:JStratum,代码行数:9,代码来源:StratumTcpServer.java

示例6: onRemoval

@Override
public void onRemoval(RemovalNotification<UUID, MapReduceTracker.RequestWrapper> notification) {
    if (notification.getCause() == RemovalCause.EXPIRED) {
        RequestWrapper wrapper = notification.getValue();
        log.warn("Timing out MapReduce request <{}> with ref count <{}>", wrapper.getClass().toString(), wrapper.pendingResponseCount.get());
        wrapper.request.onComplete(true);
    }
}
 
开发者ID:Kixeye,项目名称:kixmpp,代码行数:8,代码来源:MapReduceTracker.java


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