Cache | R Documentation |
A class that provides structure for caching objects.
type
Type of the object that are cached. All objects must be of the same type.
keys
List all key in the cache
new()
Initialize a new instance of the class
Cache$new(type = NULL)
type
Optional type constraints for object stored in the cache.
A new Cache
object.
reset()
Clear cache
Cache$reset()
set()
Store the given value in cache with the given key
Cache$set(key, value)
key
Key to use to store the value
in the case
value
Value to store in the cache
hasKey()
Check if an entry with the given key
exists in cache
Cache$hasKey(key)
key
Key to check
get()
Get cached object by key
Cache$get(key)
key
Key to use to retrieve the value
dropKey()
Remove the value associated with the key from cache.
Cache$dropKey(key)
key
Key used to find the value to remove. If the key is not found, nothing happens.
print()
Print the object to the console
Cache$print(...)
...
Rest arguments.
# Create a new instance of the class
myCache <- ospsuite:::Cache$new()
# Adding new key-value pairs
myCache$set("data1", iris)
myCache$set("data2", BOD)
# Print to see the current pairs
myCache
# Get value using a key
myCache$get("data2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.