|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrabbit.cache.ncache.NCache<K,V>
K
- the key type of the cacheV
- the data resourcepublic 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.
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. |
CacheConfiguration |
getCacheConfiguration()
Get the cache configuration for this cache. |
int |
getCleanLoopTime()
Get how long time the cleaner sleeps between cleanups. |
long |
getCurrentSize()
Get the current size of the cache |
Iterable<rabbit.cache.ncache.NCacheEntry<K,V>> |
getEntries()
Get the CacheEntries in the cache. |
CacheEntry<K,V> |
getEntry(K k)
Get the CacheEntry assosiated with given object. |
File |
getEntryName(long id,
boolean real,
String extension)
Get the file name for a cache entry. |
Logger |
getLogger()
Get the logger of 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 |
setCleanLoopTime(int newCleanLoopTime)
Set how long time the cleaner sleeps between cleanups. |
void |
setup(SProperties config)
Configure the cache system from the given config. |
void |
start()
Start the thread that cleans the cache. |
void |
stop()
Stop this cache. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NCache(SProperties props, FileHandler<K> fhk, FileHandler<V> fhv) throws IOException
props
- the configuration of the cachefhk
- the FileHandler for the cache keysfhv
- the FileHandler for the cache values
IOException
- if the cache file directory can not be configuredMethod Detail |
---|
public void start()
start
in interface Cache<K,V>
public CacheConfiguration getCacheConfiguration()
Cache
getCacheConfiguration
in interface Cache<K,V>
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
- upon failure to get the keypublic File getEntryName(long id, boolean real, String extension)
Cache
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 void addEntry(CacheEntry<K,V> ent) throws CacheException
addEntry
in interface Cache<K,V>
ent
- the CacheEntry to store.
CacheException
- if adding the entry failspublic void entryChanged(CacheEntry<K,V> ent, K newKey, V newHook) throws CacheException
entryChanged
in interface Cache<K,V>
ent
- the CacheEntry that changednewKey
- the new key of the entrynewHook
- the new value
CacheException
- if updating the cache failspublic void remove(K k) throws CacheException
remove
in interface Cache<K,V>
k
- the key for the CacheEntry.
CacheException
- if removal failspublic void clear() throws CacheException
clear
in interface Cache<K,V>
CacheException
- if the clear operation failedpublic Iterable<rabbit.cache.ncache.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
- if the new cache can not be configured correctlypublic 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 |