Permalink
Browse files

Fix absolute expiry time

Change-Id: Iaf7011285ff676cc7c4c29c7abf5e874d1d4280b
Reviewed-on: http://review.couchbase.org/13264
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Mordechai Nunberg <mnunberg@haskalah.org>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information...
1 parent ee53d20 commit c711703b35d56ba9e65fb64528030187f3d92062 @avsej avsej committed with trondn Feb 15, 2012
@@ -32,6 +32,7 @@
private volatile long casCounter = 1;
private VBucket vBucketMap[];
+ private static final long THIRTY_DAYS = 30 * 24 * 60 * 60;
public DataStore(int size) {
vBucketMap = new VBucket[size];
@@ -131,7 +132,9 @@ private Item lookup(Map<String, Item> map, String key) {
Item ii = map.get(key);
if (ii != null) {
long now = new Date().getTime();
- if (ii.getExptime() == 0 || (now - ii.getMtime() < ii.getExptimeInMillis())) {
+ if (ii.getExptime() == 0
+ || ( ii.getExptime() > THIRTY_DAYS && now < ii.getExptimeInMillis() )
+ || ( ii.getExptime() <= THIRTY_DAYS && now - ii.getMtime() < ii.getExptimeInMillis() )) {
return ii;
} else {
map.remove(key);
@@ -42,8 +42,8 @@ public int getExptime() {
return exptime;
}
- public int getExptimeInMillis() {
- return exptime * 1000;
+ public long getExptimeInMillis() {
+ return (long)exptime * 1000L;
}
public void setExptime(int e) {

0 comments on commit c711703

Please sign in to comment.