const classafIoc::ConcurrentCache

sys::Obj
  afIoc::ConcurrentCache

A map that shares its state across threads providing fast reads and synchronised writes. It's an application of ConcurrentState for use when reads far out number the writes.

The cache wraps a map stored in an AtomicRef through which all reads are made. All writes are made via ConcurrentState ensuring synchronised access. Writing makes a rw copy of the map and is thus a more expensive operation.

@since 1.4.2

containsKey

Source

Bool containsKey(Obj key)

Returns true if the cache contains the given key

get

Source

@Operator
Obj? get(Obj key)

Returns the value associated with the given key.

keys

Source

Obj[] keys()

Returns a list of all the mapped keys.

map

Source

Obj:Obj? map { private set }

A read-only copy of the cache map.

set

Source

@Operator
Void set(Obj key, Obj val)

Sets the key / value pair, ensuring no data is lost during multi-threaded race conditions. Though the same key may be overridden. Both the key and val must be immutable.

vals

Source

Obj[] vals()

Returns a list of all the mapped values.