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
Returns
true
if the cache contains the given key- get
Returns the value associated with the given key.
- keys
Obj[] keys()
Returns a list of all the mapped keys.
- map
A read-only copy of the cache map.
- set
@
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
andval
must be immutable.- vals
Obj[] vals()
Returns a list of all the mapped values.