Skip to contents

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


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.