public class QuickCache
extends java.lang.Object
implements java.util.Comparator<long[]>
Option | Time | Count | TTL |
---|---|---|---|
META_MTAC | mtime | acount | TIME |
META_MCMT | mtime | mcount | COUNT |
META_MTMC | mtime | mcount | TIME |
META_MCAT | atime | mcount | COUNT |
META_ATAC | atime | acount | TIME |
META_ACMT | mtime | acount | COUNT |
META_ATMC | atime | mcount | TIME |
META_ACAT | atime | acount | COUNT |
Modifier and Type | Field and Description |
---|---|
static int |
CACHE_EXPIRED |
static int |
CACHE_NONE |
static int |
CACHE_OFF |
static int |
CACHE_ON |
static int |
META_ACAT |
static int |
META_ACMT |
static int |
META_ATAC |
static int |
META_ATMC |
static int |
META_DEFAULT |
static int |
META_MCAT |
static int |
META_MCMT |
static int |
META_MTAC |
static int |
META_MTMC |
Constructor and Description |
---|
QuickCache(java.lang.String name,
int option,
int timeout,
int threshold) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
int |
compare(long[] a,
long[] b) |
boolean |
containsKey(java.lang.String key)
It only checks the existence of the object identified by the key,
no matter whether the object has expired or not.
|
java.lang.String[] |
disfragment() |
java.lang.String[] |
disfragment(long currentTime)
It removes all expired objects, resets all sequence numbers and returns
an array of all expired keys that have been just removed.
|
int |
expire(java.lang.String key) |
int |
expire(java.lang.String key,
long currentTime)
It expires the object and returns 0 if the ttl is larger than zero.
|
protected void |
finalize() |
java.lang.Object |
get(java.lang.String key) |
java.lang.Object |
get(java.lang.String key,
long currentTime)
It returns the object of the key only if it has not expired yet.
|
long |
getCount(java.lang.String key)
It returns the count for the object referenced by the key.
|
int[] |
getMetaData(java.lang.String key)
It returns the metadata for the object referenced by the key no matter
whether the object has expired or not.
|
long |
getMTime() |
java.lang.String |
getName() |
int |
getOption() |
int |
getStatus() |
long |
getTimeout() |
long |
getTimestamp(java.lang.String key)
It returns the timestamp for the object referenced by the key.
|
int |
getTTL(java.lang.String key)
It returns the ttl for the object referenced by the key.
|
int |
insert(java.lang.String key,
long timestamp,
int ttl,
int[] meta,
java.lang.Object obj) |
int |
insert(java.lang.String key,
long timestamp,
int ttl,
int[] meta,
java.lang.Object obj,
long currentTime)
It checks the existence of the key first.
|
protected int |
invalidate(java.lang.String key,
long currentTime)
It sets the object into null no matter what the ttl is.
|
boolean |
isExpired(java.lang.String key) |
boolean |
isExpired(java.lang.String key,
long currentTime)
It returns true if the object of the key has expired, or false otherwise.
|
java.util.Set<java.lang.String> |
keySet()
returns a set for all existing keys
|
java.lang.Object |
replace(java.lang.String key,
long timestamp,
int ttl,
int[] meta,
java.lang.Object obj) |
java.lang.Object |
replace(java.lang.String key,
long timestamp,
int ttl,
int[] meta,
java.lang.Object obj,
long currentTime)
It replaces the existing object or inserts as the new object if there
is no such key in the cache.
|
void |
setStatus(int status)
sets the CacheStatus and the modify time as the currentTime
|
void |
setStatus(int status,
long currentTime)
sets the CacheStatus and the modify time
|
int |
size() |
java.lang.Object[] |
sortedEntries() |
java.lang.String[] |
sortedKeys()
It returns an array of all the existing keys in the NATURAL order
no matter whether they have expired or not.
|
int |
touch(java.lang.String key,
long timestamp) |
int |
touch(java.lang.String key,
long timestamp,
long currentTime)
It updates mtime or mcount of the key if it has not expired at the given
currentTime yet.
|
int |
update(java.lang.String key,
long timestamp,
int ttl,
int[] meta,
java.lang.Object obj) |
int |
update(java.lang.String key,
long timestamp,
int ttl,
int[] meta,
java.lang.Object obj,
long currentTime)
It checks the existence of the key first.
|
public static final int CACHE_NONE
public static final int CACHE_ON
public static final int CACHE_OFF
public static final int CACHE_EXPIRED
public static final int META_DEFAULT
public static final int META_MTAC
public static final int META_MCMT
public static final int META_MTMC
public static final int META_MCAT
public static final int META_ATAC
public static final int META_ACMT
public static final int META_ATMC
public static final int META_ACAT
public QuickCache(java.lang.String name, int option, int timeout, int threshold)
public int size()
public java.lang.String getName()
public int getOption()
public long getTimeout()
public long getMTime()
public int getStatus()
public void setStatus(int status, long currentTime)
public void setStatus(int status)
public int insert(java.lang.String key, long timestamp, int ttl, int[] meta, java.lang.Object obj, long currentTime)
public int insert(java.lang.String key, long timestamp, int ttl, int[] meta, java.lang.Object obj)
public int update(java.lang.String key, long timestamp, int ttl, int[] meta, java.lang.Object obj, long currentTime)
public int update(java.lang.String key, long timestamp, int ttl, int[] meta, java.lang.Object obj)
public int touch(java.lang.String key, long timestamp, long currentTime)
public int touch(java.lang.String key, long timestamp)
public boolean isExpired(java.lang.String key, long currentTime)
public boolean isExpired(java.lang.String key)
public java.lang.Object replace(java.lang.String key, long timestamp, int ttl, int[] meta, java.lang.Object obj, long currentTime)
public java.lang.Object replace(java.lang.String key, long timestamp, int ttl, int[] meta, java.lang.Object obj)
public boolean containsKey(java.lang.String key)
public int getTTL(java.lang.String key)
public long getTimestamp(java.lang.String key)
public long getCount(java.lang.String key)
public int[] getMetaData(java.lang.String key)
public java.lang.Object get(java.lang.String key, long currentTime)
public java.lang.Object get(java.lang.String key)
public int expire(java.lang.String key, long currentTime)
public int expire(java.lang.String key)
protected int invalidate(java.lang.String key, long currentTime)
public java.lang.String[] disfragment(long currentTime)
public java.lang.String[] disfragment()
public java.lang.String[] sortedKeys()
public java.lang.Object[] sortedEntries()
public void clear()
protected void finalize()
finalize
in class java.lang.Object
public java.util.Set<java.lang.String> keySet()
public int compare(long[] a, long[] b)
compare
in interface java.util.Comparator<long[]>