1 17 18 package com.whirlycott.cache; 19 20 26 public class Item { 27 28 protected Object item; 29 30 31 protected long added; 32 33 34 protected long used; 35 36 37 protected long expiresAfter = -1; 38 39 40 protected volatile long count; 41 42 45 protected final Object countLock = new Object (); 46 47 public Item(final Object _item, final long _added, final long _expiresTime) { 48 item = _item; 49 added = _added; 50 expiresAfter = _expiresTime; 51 } 52 53 56 public Object getItem() { 57 return item; 58 } 59 60 void setUsed(final long _used) { 61 used = _used; 62 } 63 64 void incrementCount() { 65 synchronized(countLock) { 66 count++; 67 } 68 } 69 70 public synchronized long getAdded() { 71 return added; 72 } 73 74 public synchronized long getCount() { 75 return count; 76 } 77 78 public synchronized long getUsed() { 79 return used; 80 } 81 82 public synchronized void setCount(final long count) { 83 this.count = count; 84 } 85 86 public long getExpiresAfter() { 87 return expiresAfter; 88 } 89 } 90 91 | Popular Tags |