It is quite usual that managed instances use some form of cache.
Caches are not modelled as direct fields so that they can be changed using bindings.
In case of the Injector context this is mostly a in-memory map.
There are always steps that are repeated to set this up.
A base module binds a default map for a certain Name key to identify the cache used for the managed instance.
The managed instance resolves the cache to use it.
This would be a bit easier and more formalised in its role if there was a Cache interface for such purposes and a cache provider service that would provide the cache for the target class using the targets class as a key Name.
One benefit is that this makes the setup step of binding a default for a particular cache unnecessary.
Long term this could have the benefit of a more powerful Cache abstraction emerging that yields a suitable cache implementation based on properties provided when resolving it.
It is quite usual that managed instances use some form of cache.
Caches are not modelled as direct fields so that they can be changed using bindings.
In case of the
Injectorcontext this is mostly a in-memory map.There are always steps that are repeated to set this up.
A base module binds a default map for a certain
Namekey to identify the cache used for the managed instance.The managed instance resolves the cache to use it.
This would be a bit easier and more formalised in its role if there was a
Cacheinterface for such purposes and a cache provider service that would provide the cache for the target class using the targets class as a keyName.One benefit is that this makes the setup step of binding a default for a particular cache unnecessary.
Long term this could have the benefit of a more powerful
Cacheabstraction emerging that yields a suitable cache implementation based on properties provided when resolving it.