|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rabbit.cache.NCache<K,V>
public class NCache<K,V>
The NCache is like a Map in lookup/insert/delete The NCache is persistent over sessions (saves itself to disk). The NCache is selfcleaning, that is it removes old stuff.
Field Summary | |
---|---|
boolean |
running
|
Constructor Summary | |
---|---|
NCache(SProperties props,
FileHandler<K> fhk,
FileHandler<V> fhv)
Create a cache that uses default values. |
Method Summary | |
---|---|
void |
addEntry(CacheEntry<K,V> ent)
Insert a CacheEntry into the cache. |
void |
clear()
Clear the Cache from files. |
void |
entryChanged(CacheEntry<K,V> ent,
K newKey,
V newHook)
Signal that a cache entry have changed. |
void |
flush()
Make sure that the cache is written to the disk. |
URL |
getCacheDir()
Get the location where this cache stores its files. |
long |
getCacheTime()
Get the number of miliseconds the cache stores things usually. |
int |
getCleanLoopTime()
Get how long time the cleaner sleeps between cleanups. |
long |
getCurrentSize()
Get the current size of the cache |
Collection<rabbit.cache.NCacheEntry<K,V>> |
getEntries()
Get the CacheEntries in the cache. |
CacheEntry<K,V> |
getEntry(K k)
Get the CacheEntry assosiated with given object. |
String |
getEntryName(long id,
boolean real,
String extension)
Get the file name for a cache entry. |
FileHandler<V> |
getHookFileHandler()
Get the file handler for the values. |
FileHandler<K> |
getKeyFileHandler()
Get the file handler for the keys. |
Logger |
getLogger()
Get the logger of this cache |
long |
getMaxSize()
Get the maximum size for this cache. |
long |
getNumberOfEntries()
Get the current number of entries in the cache. |
CacheEntry<K,V> |
newEntry(K k)
Reserve space for a CacheEntry with key o. |
void |
remove(K k)
Remove the Entry with key k from the cache. |
void |
run()
Loop in a cleaning loop. |
void |
setCacheDir(String newDir)
Sets the cachedir. |
void |
setCacheTime(long newCacheTime)
Set the standard expiry-time for CacheEntries |
void |
setCleanLoopTime(int newCleanLoopTime)
Set how long time the cleaner sleeps between cleanups. |
void |
setMaxSize(long newMaxSize)
Set the maximum size for this cache. |
void |
setup(SProperties config)
Configure the cache system from the given config. |
void |
startCleaner()
|
void |
stop()
Stop this cache. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public boolean running
Constructor Detail |
---|
public NCache(SProperties props, FileHandler<K> fhk, FileHandler<V> fhv) throws IOException
IOException
Method Detail |
---|
public void startCleaner()
public URL getCacheDir()
Cache
getCacheDir
in interface Cache<K,V>
public void setCacheDir(String newDir) throws IOException
newDir
- the name of the new directory to use.
IOException
public long getMaxSize()
getMaxSize
in interface Cache<K,V>
public void setMaxSize(long newMaxSize)
setMaxSize
in interface Cache<K,V>
newMaxSize
- the new maximum size for the cache.public long getCacheTime()
getCacheTime
in interface Cache<K,V>
public void setCacheTime(long newCacheTime)
setCacheTime
in interface Cache<K,V>
newCacheTime
- the number of miliseconds to keep objects normally.public int getCleanLoopTime()
public void setCleanLoopTime(int newCleanLoopTime)
newCleanLoopTime
- the number of miliseconds to sleep.public long getCurrentSize()
getCurrentSize
in interface Cache<K,V>
public long getNumberOfEntries()
getNumberOfEntries
in interface Cache<K,V>
public CacheEntry<K,V> getEntry(K k) throws CacheException
getEntry
in interface Cache<K,V>
k
- the key.
CacheException
public String getEntryName(long id, boolean real, String extension)
getEntryName
in interface Cache<K,V>
id
- the id of the cache entryreal
- false if this is a temporary cache file,
true if it is a realized entry.extension
- the cache entry extension.public CacheEntry<K,V> newEntry(K k)
newEntry
in interface Cache<K,V>
k
- the key for the CacheEntry.
public FileHandler<K> getKeyFileHandler()
Cache
getKeyFileHandler
in interface Cache<K,V>
public FileHandler<V> getHookFileHandler()
Cache
getHookFileHandler
in interface Cache<K,V>
public void addEntry(CacheEntry<K,V> ent) throws CacheException
addEntry
in interface Cache<K,V>
ent
- the CacheEntry to store.
CacheException
public void entryChanged(CacheEntry<K,V> ent, K newKey, V newHook) throws CacheException
entryChanged
in interface Cache<K,V>
CacheException
public void remove(K k) throws CacheException
remove
in interface Cache<K,V>
k
- the key for the CacheEntry.
CacheException
public void clear() throws CacheException
clear
in interface Cache<K,V>
CacheException
public Collection<rabbit.cache.NCacheEntry<K,V>> getEntries()
getEntries
in interface Cache<K,V>
public void flush()
flush
in interface Cache<K,V>
public void run()
run
in interface Runnable
public void stop()
Cache
stop
in interface Cache<K,V>
public void setup(SProperties config) throws IOException
config
- the properties describing the cache settings.
IOException
public Logger getLogger()
Cache
getLogger
in interface Cache<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |