com.holmos.cache.status.CacheStatus Maven / Gradle / Ivy
package com.holmos.cache.status;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
/**
* 缓存的状态信息
* @author: 吴银龙([email protected])
* @version: 2013-3-12 下午10:13:50
*/
public class CacheStatus {
private AtomicLongFieldUpdater DATA_MOUNT= AtomicLongFieldUpdater.newUpdater(CacheStatus.class, "dataMount");
private AtomicLongFieldUpdater USED_SIZE= AtomicLongFieldUpdater.newUpdater(CacheStatus.class, "usedSize");
private AtomicLongFieldUpdater VISIT_TIMES= AtomicLongFieldUpdater.newUpdater(CacheStatus.class, "visitTimes");
private AtomicLongFieldUpdater UPDATE_TIMES= AtomicLongFieldUpdater.newUpdater(CacheStatus.class, "updateTimes");
private AtomicLongFieldUpdater HIT_TIMES= AtomicLongFieldUpdater.newUpdater(CacheStatus.class, "hitTimes");
/**缓存的层级*/
private byte level;
/**缓存元素个数*/
private long dataMount;
/**已用缓存大小,单位Byte*/
private long usedSize;
public byte getLevel() {
return level;
}
public void setLevel(byte level) {
this.level = level;
}
public long getDataMount() {
return dataMount;
}
public void setDataMount(long dataMount) {
this.dataMount = dataMount;
}
public long getUsedSize() {
return usedSize;
}
public void setUsedSize(long usedSize) {
this.usedSize = usedSize;
}
public long getVisitTimes() {
return visitTimes;
}
public void setVisitTimes(long visitTimes) {
this.visitTimes = visitTimes;
}
public long getUpdateTimes() {
return updateTimes;
}
public void setUpdateTimes(long updateTimes) {
this.updateTimes = updateTimes;
}
public long getPutTimes() {
return putTimes;
}
public void setPutTimes(long putTimes) {
this.putTimes = putTimes;
}
public long getLiveTime() {
return liveTime;
}
public void setLiveTime(long liveTime) {
this.liveTime = liveTime;
}
public long getHitTimes() {
return hitTimes;
}
public void setHitTimes(long hitTimes) {
this.hitTimes = hitTimes;
}
public long getMissTime() {
return missTime;
}
public void setMissTime(long missTime) {
this.missTime = missTime;
}
/**缓存读取次数*/
private long visitTimes;
/**缓存更新次数,指对以前缓存中已有数据的更新次数*/
private long updateTimes;
/**缓存写入次数,指原来在缓存中没有的数据*/
private long putTimes;
/**缓存数据的存活时间*/
private long liveTime;
/**命中次数*/
private long hitTimes;
/**没有命中的次数*/
private long missTime;
public void increaceHitTime(){
HIT_TIMES.incrementAndGet(this);
VISIT_TIMES.incrementAndGet(this);
}
public void increaceVisitTime(){
VISIT_TIMES.incrementAndGet(this);
}
public void increaceUpdateTime(){
VISIT_TIMES.incrementAndGet(this);
UPDATE_TIMES.incrementAndGet(this);
}
public void increaceDataMount(){
DATA_MOUNT.incrementAndGet(this);
}
public void decreaceDataMount(){
DATA_MOUNT.decrementAndGet(this);
}
public void addUsedSize(long size){
USED_SIZE.addAndGet(this, size);
}
public void minusUsedSize(long size){
USED_SIZE.addAndGet(this, 0 - size );
}
}