const mixinafIoc::ThreadLocalManager
afIoc::ThreadLocalManager
(Service) - Use to create LocalRef instances whose contents can be cleaned up. Erm, I mean deleted!
This is particularly important in the context of web applications where resources need to be cleaned up at the end of a web request / thread.
LocalRef instances may also be injected directed into your classes:
const class Example {
@Inject const LocalMap localMap
new make(|This|in) { in(this) }
}
Then when cleanUpThread() is called, all thread local data created by this manager will be deleted from Actor.locals
@since 1.6.0
- addCleanUpHandler
abstract Void addCleanUpHandler(|->Void handler)Add a handler to be called on thread clean up. Handlers need to be added for each thread.
- cleanUpThread
abstract Void cleanUpThread()Removes all values in the current thread associated / used with this manager.
- createList
abstract LocalList createList(Str name)Creates a LocalList with the given name.
- createMap
abstract LocalMap createMap(Str name)Creates a LocalMap with the given name.
- createRef
abstract LocalRef createRef(Str name, Obj? def := null)Creates a LocalRef with the given name.
- keys
abstract Str[] keys()Returns all (fully qualified) keys in the current thread associated / used with this manager.