ESCacheElement.java 676 Bytes
package com.zhaoonline.es.cache;

import org.springframework.cache.support.SimpleValueWrapper;

public class ESCacheElement extends SimpleValueWrapper {
	private final ESCacheKey cacheKey;
	private long timeToLive;

	public ESCacheElement(ESCacheKey cacheKey,Object value) {
		super(value);
		this.cacheKey=cacheKey;
		
	}
	public void setTimeToLive(long timeToLive) {
		this.timeToLive = timeToLive;
	}
	public long getTimeToLive() {
		return timeToLive;
	}
	
	public ESCacheKey getCacheKey() {
		return cacheKey;
	}
	public boolean isEternal() {
		return 0 == timeToLive;
	}
	
	public ESCacheElement expireAfter(long seconds) {
		setTimeToLive(seconds);
		return this;
	}
}