Package org.apache.sling.scripting.api

# Interface ScriptCache

public interface ScriptCache
The `ScriptCache` service interface defines a cache for compiled scripts. Implementations of this interface should be thread-safe.

## Method Summary

Modifier and Type
Method
Description
`void`
`clear()`
Empties the cache.
`CachedScript`
`getScript(String scriptPath)`
Retrieves the `CachedScript` corresponding to the script accessible from the `scriptPath`.
`void`
`putScript(CachedScript script)`
Stores a `CachedScript` in the cache.
`boolean`
`removeScript(String scriptPath)`
Removes the script identified by `scriptPath` from the cache.

## Method Details

### getScript

CachedScript getScript(String scriptPath)
Retrieves the `CachedScript` corresponding to the script accessible from the `scriptPath`.

Parameters:
  `scriptPath` - the path from where the script can be accessed
Returns:
  the `CachedScript` if one exists, `null` otherwise

### putScript

void putScript(CachedScript script)
Stores a `CachedScript` in the cache. If a previous version of it exist in the cache it is overridden.

Parameters:
  `script` - the `CachedScript` that should be stored in the cache

### clear

void clear()
Empties the cache.

### removeScript

boolean removeScript(String scriptPath)
Removes the script identified by `scriptPath` from the cache.

Parameters:
  `scriptPath` - the path from where the script can be accessed
Returns:
  `true` if a script was cached from that path and was removed, `false` otherwise