org.norther.tammi.core.cache
Interface SharedCache

All Superinterfaces:
Cache, CachedMap, ConcurrentMap, Map
All Known Implementing Classes:
DefaultSharedCache

public interface SharedCache
extends Cache

Extends Cache to support double hashing by adding a set of access methods with an additional domain key. The domain key is automatically mapped to a domain specific cache. If the domain is not given, the default domain cache is used.

Author:
Ilkka Priha

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 void clear(String domain)
          Clears the specified domain map.
 void clearDomains()
          Clears all domain caches.
 boolean containsDomain(String domain)
          Checks whether a domain has a cache.
 boolean containsKey(String domain, Object key)
          Checks a key from the specified domain map.
 boolean containsValue(String domain, Object obj)
          Checks a value from the specified domain map.
 Set domainSet()
          Returns a set of defined domains.
 Set entrySet(String domain)
          Gets an entry set from the specified domain map.
 Object expire(String domain, Object key)
          Expires and removes a value from the specified domain map.
 void expireAll(String domain)
          Expires all values from the specified domain map.
 void expireAllDomains()
          Expires all values from all domain caches.
 void expireFraction(String domain, float fraction)
          Expires a fraction of entries.
 Object get(String domain, Object key)
          Gets a value from the specified domain map.
 Object get(String domain, Object key, int freq)
          Gets a value from the the specified domain map and refreshes it with a specified expiration frequency.
 int getDefaultExpirationTime(String domain)
          Gets the default expiration time of the domain in seconds.
 CachedMap getDomainCache(String domain)
          Gets the cache of the specified domain.
 CachedMap getDomainCache(String domain, boolean create)
          Gets and optionally creates the cache of the specified domain.
 int getExpirationLimit(String domain)
          Gets the expiration limit in the domain.
 int getExpirationSleepInterval(String domain)
          Gets the expiration sleep interval of the domain in seconds.
 float getExpirationThreshold(String domain)
          Gets the expiration threshold in the domain.
 int getMaxExpirationTime(String domain)
          Gets the maximum expiration time of the domain in seconds.
 boolean isAllowExpired(String domain)
          Gets the allow expired option of the domain.
 boolean isDiscardOverloaded(String domain)
          Gets the discard overloaded option of the domain.
 boolean isEmpty(String domain)
          Checks if the specified domain map is empty.
 Set keySet(String domain)
          Gets a key set from the specified domain map.
 Object put(String domain, Object key, Object obj)
          Puts a value to the specified domain map.
 Object put(String domain, Object key, Object obj, int freq)
          Puts a value to the specified domain map with a value specific expiration frequency.
 void putAll(String domain, Map map)
          Puts a map to the specified domain map.
 boolean refresh(String domain, Object key)
          Refreshes a value in the specified domain map.
 boolean refresh(String domain, Object key, int freq)
          Refreshes a value in the specified domain map with a new frequency.
 Object remove(String domain, Object key)
          Removes a value from the specified domain map.
 void removeDomain(String domain)
          Removes the specified domain.
 void setAllowExpired(String domain, boolean flag)
          Sets the allow expired option of the domain allowing gets of entries already expired but not yet removed by the expiration handler.
 void setDefaultExpirationTime(String domain, int t)
          Sets the default expiration time of the domain in seconds.
 void setDiscardOverloaded(String domain, boolean flag)
          Sets the discard overloaded option of the domain.
 void setExpirationLimit(String domain, int c)
          Sets the expiration limit in the domain.
 void setExpirationSleepInterval(String domain, int t)
          Sets the expiration sleep interval of the domain in seconds.
 void setExpirationThreshold(String domain, float h)
          Gets the expiration threshold in the domain.
 void setMaxExpirationTime(String domain, int t)
          Sets the maximum expiration time of the domain in seconds.
 int size(String domain)
          Gets the size of the specified domain map.
 Collection values(String domain)
          Gets a collection of values from the specified domain map.
 
Methods inherited from interface org.norther.tammi.acorn.cache.CachedMap
add, add, expire, expireAll, expireFraction, get, getDefaultExpirationTime, getExpirationLimit, getExpirationSleepInterval, getExpirationThreshold, getMaxExpirationTime, isAllowExpired, isAutoRefreshDeclined, isDiscardOverloaded, put, putIfAbsent, refresh, refresh, setAllowExpired, setAutoRefreshDeclined, setDefaultExpirationTime, setDiscardOverloaded, setExpirationLimit, setExpirationSleepInterval, setExpirationThreshold, setMaxExpirationTime
 
Methods inherited from interface java.util.concurrent.ConcurrentMap
putIfAbsent, remove, replace, replace
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Method Detail

isAllowExpired

boolean isAllowExpired(String domain)
Gets the allow expired option of the domain.

Parameters:
domain - the domain.
Returns:
the allow expired option.

setAllowExpired

void setAllowExpired(String domain,
                     boolean flag)
Sets the allow expired option of the domain allowing gets of entries already expired but not yet removed by the expiration handler.

Parameters:
domain - the domain.
flag - the allow expired option.

isDiscardOverloaded

boolean isDiscardOverloaded(String domain)
Gets the discard overloaded option of the domain.

Parameters:
domain - the domain.
Returns:
true if new puts are discarded if overloaded, false otherwise.

setDiscardOverloaded

void setDiscardOverloaded(String domain,
                          boolean flag)
Sets the discard overloaded option of the domain. If set to true, new entries are discarded and an exception thrown when the capacity of the cache is exceeded. The default policy is to expire old entries until enough capacity is available.

Parameters:
domain - the domain.
flag - true if new puts are discarded if overloaded, false otherwise.

getMaxExpirationTime

int getMaxExpirationTime(String domain)
Gets the maximum expiration time of the domain in seconds.

Parameters:
domain - the domain.
Returns:
the secs.

setMaxExpirationTime

void setMaxExpirationTime(String domain,
                          int t)
Sets the maximum expiration time of the domain in seconds.

Parameters:
domain - the domain.
t - the secs.

getDefaultExpirationTime

int getDefaultExpirationTime(String domain)
Gets the default expiration time of the domain in seconds.

Parameters:
domain - the domain.
Returns:
the secs.

setDefaultExpirationTime

void setDefaultExpirationTime(String domain,
                              int t)
Sets the default expiration time of the domain in seconds.

Parameters:
domain - the domain.
t - the secs.

getExpirationSleepInterval

int getExpirationSleepInterval(String domain)
Gets the expiration sleep interval of the domain in seconds.

Parameters:
domain - the domain.
Returns:
the secs.

setExpirationSleepInterval

void setExpirationSleepInterval(String domain,
                                int t)
Sets the expiration sleep interval of the domain in seconds.

Parameters:
domain - the domain.
t - the secs

getExpirationLimit

int getExpirationLimit(String domain)
Gets the expiration limit in the domain.

Parameters:
domain - the domain.
Returns:
the limit.

setExpirationLimit

void setExpirationLimit(String domain,
                        int c)
Sets the expiration limit in the domain.

Parameters:
domain - the domain.
c - the limit.

getExpirationThreshold

float getExpirationThreshold(String domain)
Gets the expiration threshold in the domain.

Parameters:
domain - the domain.
Returns:
the threshold.

setExpirationThreshold

void setExpirationThreshold(String domain,
                            float h)
Gets the expiration threshold in the domain.

Parameters:
domain - the domain.
h - the threshold.

clear

void clear(String domain)
Clears the specified domain map.

Parameters:
domain - the domain.

containsValue

boolean containsValue(String domain,
                      Object obj)
Checks a value from the specified domain map.

Parameters:
domain - the domain.
obj - the value to check.
Returns:
true if the value was found.

containsKey

boolean containsKey(String domain,
                    Object key)
Checks a key from the specified domain map.

Parameters:
domain - the domain.
key - the key to check.
Returns:
true if the key was found.

entrySet

Set entrySet(String domain)
Gets an entry set from the specified domain map.

Parameters:
domain - the domain.
Returns:
an entry set.

keySet

Set keySet(String domain)
Gets a key set from the specified domain map.

Parameters:
domain - the domain.
Returns:
a key set.

values

Collection values(String domain)
Gets a collection of values from the specified domain map.

Parameters:
domain - the domain.
Returns:
a collection.

get

Object get(String domain,
           Object key)
Gets a value from the specified domain map.

Parameters:
domain - the domain.
key - the key.
Returns:
the value or null.

put

Object put(String domain,
           Object key,
           Object obj)
Puts a value to the specified domain map.

Parameters:
domain - the domain.
key - the key.
obj - the value.
Returns:
the previous value or null.

putAll

void putAll(String domain,
            Map map)
Puts a map to the specified domain map.

Parameters:
domain - the domain.
map - the map.

remove

Object remove(String domain,
              Object key)
Removes a value from the specified domain map.

Parameters:
domain - the domain.
key - the key.
Returns:
the removed value or null.

size

int size(String domain)
Gets the size of the specified domain map.

Parameters:
domain - the domain.
Returns:
the size.

isEmpty

boolean isEmpty(String domain)
Checks if the specified domain map is empty.

Parameters:
domain - the domain.
Returns:
true if the map is empty.

get

Object get(String domain,
           Object key,
           int freq)
Gets a value from the the specified domain map and refreshes it with a specified expiration frequency.

Parameters:
domain - the domain.
key - the key.
freq - the expiration frequency.
Returns:
the value or null.

put

Object put(String domain,
           Object key,
           Object obj,
           int freq)
Puts a value to the specified domain map with a value specific expiration frequency.

Parameters:
domain - the domain.
key - the key.
obj - the value.
freq - the expiration frequency.
Returns:
the previous value or null.

refresh

boolean refresh(String domain,
                Object key)
Refreshes a value in the specified domain map.

Parameters:
domain - the domain.
key - the key.
Returns:
true if refreshed, false otherwise.

refresh

boolean refresh(String domain,
                Object key,
                int freq)
Refreshes a value in the specified domain map with a new frequency.

Parameters:
domain - the domain.
key - the key.
freq - the expiration frequency.
Returns:
true if refreshed, false otherwise.

expire

Object expire(String domain,
              Object key)
Expires and removes a value from the specified domain map.

Parameters:
domain - the domain.
key - the key.
Returns:
the expired value or null.

expireAll

void expireAll(String domain)
Expires all values from the specified domain map.

Parameters:
domain - the domain.

expireFraction

void expireFraction(String domain,
                    float fraction)
Expires a fraction of entries.

Parameters:
domain - the domain.
fraction - the fraction to expire (0.0..1.0).
Throws:
IllegalArgumentException - for an invalid fragment.

getDomainCache

CachedMap getDomainCache(String domain)
Gets the cache of the specified domain.

Parameters:
domain - the domain.
Returns:
the domain cache or null.

getDomainCache

CachedMap getDomainCache(String domain,
                         boolean create)
Gets and optionally creates the cache of the specified domain.

Parameters:
domain - the domain.
create - true to create a missing cache.
Returns:
the domain cache.

containsDomain

boolean containsDomain(String domain)
Checks whether a domain has a cache.

Parameters:
domain - the domain.
Returns:
true if the domain was found.

removeDomain

void removeDomain(String domain)
Removes the specified domain.

Parameters:
domain - the domain.

domainSet

Set domainSet()
Returns a set of defined domains.

Returns:
a read-only set of domains.

clearDomains

void clearDomains()
Clears all domain caches.


expireAllDomains

void expireAllDomains()
Expires all values from all domain caches.



Copyright © 2004 The Norther Organization. All rights reserved.