const classafIoc::ThreadStash

sys::Obj
  afIoc::ThreadStash

A wrapper around Actor.locals ensuring a unique namespace per instance. this means you don't have to worry about name clashes.

Example usage:

stash1 := ThreadStash("prefix")
stash1["wot"] = "ever"

stash2 := ThreadStash("prefix")
stash2["wot"] = "banana"

Obj.echo(stash1["wot"])  // --> ever

Though typically you would create calculated field wrappers:

const class Example
  private const ThreadStash stash := LocalStash(typeof.name)
  
  MyService wotever {
    get { stash["wotever"] }
    set { stash["wotever"] = it }
  }
}

@since 1.3.0 (a replacement for LocalStash)

clear

Source

Void clear()

Removes all key/value pairs from this stash

get

Source

@Operator
Obj? get(Str name, |->Obj? defFunc := null)

Get the value for the specified name.

keys

Source

Str[] keys()

Returns all (fully qualified) keys associated / used with this stash

make

Source

new make(Str prefix)

remove

Source

Obj? remove(Str name)

Remove the name/value pair from the stash and returns the value that was. If the name was not mapped then return null.

set

Source

@Operator
Void set(Str name, Obj? value)

Set the value for the specified name. If the name was already mapped, this overwrites the old value.