Cache (RabbIT/4)
Date: 2009-10-13

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rabbit.cache
Interface Cache<K,V>

All Known Implementing Classes:
  NCache

    public interface Cache<K,V>

A cache, mostly works like a map in lookup, insert and delete. A cache may be persistent over sessions. A cache may clean itself over time.

Author:
  Robert Olofsson

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 newValue)` 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.
`long` | `getCurrentSize()` Get the current size of the cache
`Collection<CacheEntry<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.
`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 o from the cache.
`void` | `setCacheTime(long newCacheTime)` Set the standard expiry-time for CacheEntries
`void` | `setMaxSize(long newMaxSize)` Set the maximum size for this cache.
`void` | `stop()` Stop this cache.

Method Detail

### getMaxSize

    long getMaxSize()

  Get the maximum size for this cache.

  Returns:
    the maximum size in bytes this cache.

### setMaxSize

    void setMaxSize(long newMaxSize)

  Set the maximum size for this cache.

  Parameters:
    `newMaxSize` - the new maximum size for the cache.

### getCacheTime

    long getCacheTime()

  Get the number of miliseconds the cache stores things usually. This is the standard expiretime for objects, but you can set it for CacheEntries individially if you want to. NOTE 1: dont trust that an object will be in the cache this long. NOTE 2: dont trust that an object will be removed from the cache when it expires.

  Returns:
    the number of miliseconds objects are stored normally.

### setCacheTime

    void setCacheTime(long newCacheTime)

  Set the standard expiry-time for CacheEntries

  Parameters:
    `newCacheTime` - the number of miliseconds to keep objects normally.

### getCurrentSize

    long getCurrentSize()

  Get the current size of the cache

  Returns:
    the current size of the cache in bytes.

### getNumberOfEntries

    long getNumberOfEntries()

  Get the current number of entries in the cache.

  Returns:
    the current number of entries in the cache.

### getCacheDir

    URL getCacheDir()

  Get the location where this cache stores its files.

  Returns:
    the location, null if no physical location is used.

### getEntry

    CacheEntry<K,V> getEntry(K k)

  Get the CacheEntry assosiated with given object.

  Parameters:
    `k` - the key.
  Returns:
    the NCacheEntry or null (if not found).

### getEntryName

    String getEntryName(long id,
                        boolean real,
                        String extension)

  Get the file name for a cache entry.

  Parameters:
    `id` - the id of the cache entry
    `real` - false if this is a temporary cache file, true if it is a realized entry.
    `extension` - the cache entry extension.

### getKeyFileHandler

    FileHandler<K> getKeyFileHandler()

  Get the file handler for the keys.

### getHookFileHandler

    FileHandler<V> getHookFileHandler()

  Get the file handler for the values.

### newEntry

    CacheEntry<K,V> newEntry(K k)

  Reserve space for a CacheEntry with key o.

  Parameters:
    `k` - the key for the CacheEntry.
  Returns:
    a new CacheEntry initialized for the cache.

### addEntry

    void addEntry(CacheEntry<K,V> ent)

  Insert a CacheEntry into the cache.

  Parameters:
    `ent` - the CacheEntry to store.

### entryChanged

    void entryChanged(CacheEntry<K,V> ent,
                      K newKey,
                      V newValue)

  Signal that a cache entry have changed.

### remove

    void remove(K k)

  Remove the Entry with key o from the cache.

  Parameters:
    `k` - the key for the CacheEntry.

### clear

    void clear()

  Clear the Cache from files.

### getEntries

    Collection<CacheEntry<K,V>> getEntries()

  Get the CacheEntries in the cache.

  Returns:
    an Enumeration of the CacheEntries.

### flush

    void flush()

  Make sure that the cache is written to the disk.

### stop

    void stop()

  Stop this cache. If this cache is using any cleaner threads they have to be stopped when this method is called.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD