Class LRUNonThreadSafeCompiledScriptCache
java.lang.Object
org.openspaces.remoting.scripting.cache.LRUNonThreadSafeCompiledScriptCache
- All Implemented Interfaces:
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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLRUNonThreadSafeCompiledScriptCache(int cacheSize) LRUNonThreadSafeCompiledScriptCache(int cacheSize, CompiledScriptPoolFactory compiledScriptPoolFactory) -
Method Summary
Modifier and TypeMethodDescriptionget(String name, LocalScriptExecutor executor, Script script) Gets the compiled script from the cache.voidput(String name, Object compiledScript, LocalScriptExecutor executor) Puts a compiled script back to the cache.
-
Field Details
-
DEFAULT_CACHE_SIZE
public static final int DEFAULT_CACHE_SIZE- See Also:
-
-
Constructor Details
-
LRUNonThreadSafeCompiledScriptCache
public LRUNonThreadSafeCompiledScriptCache() -
LRUNonThreadSafeCompiledScriptCache
public LRUNonThreadSafeCompiledScriptCache(int cacheSize) -
LRUNonThreadSafeCompiledScriptCache
public LRUNonThreadSafeCompiledScriptCache(int cacheSize, CompiledScriptPoolFactory compiledScriptPoolFactory)
-
-
Method Details
-
get
public Object get(String name, LocalScriptExecutor executor, Script script) throws ScriptCompilationException Description copied from interface:CompiledScriptCacheGets the compiled script from the cache. Compiles it if a new instance is needed using the provided local executor.- Specified by:
getin interfaceCompiledScriptCache- 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
Description copied from interface:CompiledScriptCachePuts a compiled script back to the cache.- Specified by:
putin interfaceCompiledScriptCache- 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
-