public enum CacheLRUWrapper extends java.lang.Enum<CacheLRUWrapper>
Enum Constant and Description |
---|
INSTANCE |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CACHE_INDEX_FILE_NAME |
Modifier and Type | Method and Description |
---|---|
boolean |
addEntry(java.lang.String key,
java.lang.String path)
This adds a new entry to file.
|
boolean |
contains(java.lang.String key)
Test if we the key provided is in use.
|
java.lang.String |
generateKey(java.lang.String path)
Generate a key given the path to file.
|
static CacheLRUWrapper |
getInstance()
Returns an instance of the policy.
|
java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getLRUSortedEntries()
Return a copy of the keys available.
|
java.lang.String |
getValue(java.lang.String key)
Return the value of given key.
|
void |
load()
Update map for keeping track of recently used items.
|
void |
lock()
Lock the file to have exclusive access.
|
boolean |
removeEntry(java.lang.String key)
This removed an entry from our map.
|
void |
store()
Write file to disk.
|
void |
unlock()
Unlock the file.
|
boolean |
updateEntry(java.lang.String oldKey)
This updates the given key to reflect it was recently accessed.
|
static CacheLRUWrapper |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static CacheLRUWrapper[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final CacheLRUWrapper INSTANCE
public static final java.lang.String CACHE_INDEX_FILE_NAME
public static CacheLRUWrapper[] values()
for (CacheLRUWrapper c : CacheLRUWrapper.values()) System.out.println(c);
public static CacheLRUWrapper valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified namejava.lang.NullPointerException
- if the argument is nullpublic static CacheLRUWrapper getInstance()
public void load()
public void store()
public boolean addEntry(java.lang.String key, java.lang.String path)
key
- key we want path to be associated with.path
- path to cache item.public boolean removeEntry(java.lang.String key)
key
- key we want to remove.public boolean updateEntry(java.lang.String oldKey)
oldKey
- Key we wish to update.public java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> getLRUSortedEntries()
public void lock()
public void unlock()
public java.lang.String getValue(java.lang.String key)
key
- public boolean contains(java.lang.String key)
key
- key to be tested.public java.lang.String generateKey(java.lang.String path)
path
- Path to generate a key with.