Cache: Cache

CacheR Documentation

Cache

Description

A class that provides structure for caching objects.

Public fields

type

Type of the object that are cached. All objects must be of the same type.

Active bindings

keys

List all key in the cache

Methods

Public methods


Method new()

Initialize a new instance of the class

Usage
Cache$new(type = NULL)
Arguments
type

Optional type constraints for object stored in the cache.

Returns

A new Cache object.


Method reset()

Clear cache

Usage
Cache$reset()

Method set()

Store the given value in cache with the given key

Usage
Cache$set(key, value)
Arguments
key

Key to use to store the value in the case

value

Value to store in the cache


Method hasKey()

Check if an entry with the given key exists in cache

Usage
Cache$hasKey(key)
Arguments
key

Key to check


Method get()

Get cached object by key

Usage
Cache$get(key)
Arguments
key

Key to use to retrieve the value


Method dropKey()

Remove the value associated with the key from cache.

Usage
Cache$dropKey(key)
Arguments
key

Key used to find the value to remove. If the key is not found, nothing happens.


Method print()

Print the object to the console

Usage
Cache$print(...)
Arguments
...

Rest arguments.

Examples

# 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")


Open-Systems-Pharmacology/OSPSuite-R documentation built on April 28, 2024, 2:24 a.m.