GigaSpaces XAP 7.0 API

org.openspaces.remoting.scripting.cache
Class LRUNonThreadSafeCompiledScriptCache

java.lang.Object
  extended by org.openspaces.remoting.scripting.cache.LRUNonThreadSafeCompiledScriptCache
All Implemented Interfaces:
CompiledScriptCache

public class LRUNonThreadSafeCompiledScriptCache
extends Object
implements CompiledScriptCache

An LRU cache that can handle compiled scripts that are not thread safe. Non thread safe compiled scripts are scripts that can not be executed by more than one thread at once.

The cache holds a CompiledScriptPool per script name, and allocates a pool when a new one is required. The pool allows to get and put compiled scripts.

Uses a simple LinkedHashMap to implement the LRU.

Author:
kimchy

Field Summary
static int DEFAULT_CACHE_SIZE
           
 
Constructor Summary
LRUNonThreadSafeCompiledScriptCache()
           
LRUNonThreadSafeCompiledScriptCache(int cacheSize)
           
LRUNonThreadSafeCompiledScriptCache(int cacheSize, CompiledScriptPoolFactory compiledScriptPoolFactory)
           
 
Method Summary
 Object get(String name, LocalScriptExecutor executor, Script script)
          Gets the compiled script from the cache.
 void put(String name, Object compiledScript, LocalScriptExecutor executor)
          Puts a compiled script back to the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CACHE_SIZE

public static final int DEFAULT_CACHE_SIZE
See Also:
Constant Field Values
Constructor Detail

LRUNonThreadSafeCompiledScriptCache

public LRUNonThreadSafeCompiledScriptCache()

LRUNonThreadSafeCompiledScriptCache

public LRUNonThreadSafeCompiledScriptCache(int cacheSize)

LRUNonThreadSafeCompiledScriptCache

public LRUNonThreadSafeCompiledScriptCache(int cacheSize,
                                           CompiledScriptPoolFactory compiledScriptPoolFactory)
Method Detail

get

public Object get(String name,
                  LocalScriptExecutor executor,
                  Script script)
           throws ScriptCompilationException
Description copied from interface: CompiledScriptCache
Gets the compiled script from the cache. Compiles it if a new instance is needed using the provided local executor.

Specified by:
get in interface CompiledScriptCache
Parameters:
name - The name (key) in the cache.
executor - The executor to use to compile the script.
script - The script to compile
Returns:
A compiled script from the cache
Throws:
ScriptCompilationException

put

public void put(String name,
                Object compiledScript,
                LocalScriptExecutor executor)
Description copied from interface: CompiledScriptCache
Puts a compiled script back to the cache.

Specified by:
put in interface CompiledScriptCache
Parameters:
name - The name (key) in the cache)
compiledScript - The compiled script to put back in the cache.
executor - The executor to use in order to close any evicted compiled scripts from the cache

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.