org.red5.server.cache
Class WhirlyCacheImpl

java.lang.Object
  extended by org.red5.server.cache.WhirlyCacheImpl
All Implemented Interfaces:
ICacheStore, org.springframework.context.ApplicationContextAware

public class WhirlyCacheImpl
extends Object
implements ICacheStore, org.springframework.context.ApplicationContextAware

Provides an implementation of an object cache using whirlycache.

Author:
The Red5 Project (red5@osflash.org), Paul Gregoire (mondain@gmail.com)
See Also:
whirlycache homepage

Field Summary
protected static org.slf4j.Logger log
           
 
Constructor Summary
WhirlyCacheImpl()
           
 
Method Summary
 void destroy()
          Shuts cache manager down
 ICacheable get(String name)
          Returns cachable object by name
static org.springframework.context.ApplicationContext getApplicationContext()
          Returns Spring application context used by this class
static long getCacheHit()
          Returns cache hits stats
static long getCacheMiss()
          Returns cache misses stats
 Iterator<String> getObjectNames()
          Iterate thru names of objects in cache.
 Iterator<SoftReference<? extends ICacheable>> getObjects()
          Iterate thru names of objects in cache with soft reference.
 void init()
          Initialazing method
 boolean offer(String name, Object obj)
          Stores object in the cache
 void put(String name, Object obj)
          Puts object in cache under given name, overloaded method.
 boolean remove(ICacheable obj)
          Removes object from cache
 boolean remove(String name)
          Removes object from cache by name
 void setApplicationContext(org.springframework.context.ApplicationContext context)
          
 void setCacheConfig(com.whirlycott.cache.CacheConfiguration cacheConfig)
          Sets cache configuration
 void setMaxEntries(int capacity)
          Sets the maximum number of entries for the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.slf4j.Logger log
Constructor Detail

WhirlyCacheImpl

public WhirlyCacheImpl()
Method Detail

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext context)
                           throws org.springframework.beans.BeansException

Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

getApplicationContext

public static org.springframework.context.ApplicationContext getApplicationContext()
Returns Spring application context used by this class

Returns:
Spring application context object

init

public void init()
Initialazing method


get

public ICacheable get(String name)
Returns cachable object by name

Specified by:
get in interface ICacheStore
Parameters:
name - Object name
Returns:
the object or null if no such object was found

put

public void put(String name,
                Object obj)
Puts object in cache under given name, overloaded method.

Specified by:
put in interface ICacheStore
Parameters:
name - Name
obj - Object to store in cache

getObjectNames

public Iterator<String> getObjectNames()
Iterate thru names of objects in cache. To be implemented!

Specified by:
getObjectNames in interface ICacheStore
Returns:
Iterator

getObjects

public Iterator<SoftReference<? extends ICacheable>> getObjects()
Iterate thru names of objects in cache with soft reference. To be implemented!

Specified by:
getObjects in interface ICacheStore
Returns:
iterator over all objects

offer

public boolean offer(String name,
                     Object obj)
Stores object in the cache

Specified by:
offer in interface ICacheStore
Parameters:
name - Name of stored object
obj - Object to store
Returns:
true if accepted, false otherwise

remove

public boolean remove(ICacheable obj)
Removes object from cache

Specified by:
remove in interface ICacheStore
Parameters:
obj - Object to remove from cache
Returns:

remove

public boolean remove(String name)
Removes object from cache by name

Specified by:
remove in interface ICacheStore
Parameters:
name - Name of object to remove
Returns:

setCacheConfig

public void setCacheConfig(com.whirlycott.cache.CacheConfiguration cacheConfig)
Sets cache configuration

Parameters:
cacheConfig - Cache configuration

setMaxEntries

public void setMaxEntries(int capacity)
Description copied from interface: ICacheStore
Sets the maximum number of entries for the cache.

Specified by:
setMaxEntries in interface ICacheStore
Parameters:
capacity - upper-limit of the cache

getCacheHit

public static long getCacheHit()
Returns cache hits stats

Returns:
cache hits stats

getCacheMiss

public static long getCacheMiss()
Returns cache misses stats

Returns:
cache misses stats

destroy

public void destroy()
Shuts cache manager down

Specified by:
destroy in interface ICacheStore


Copyright © 2006-2007 the Red5 project.