Does `multiton` keeps in memory after new instance...
# kodein
i
Does
multiton
keeps in memory after new instance of object requested? If yes can i somehow change that behavior?
i
sounds like you want a factory
multiton is singleton + factory so each "key" guarantees a singleton instance
i
I want to keep instance in memory until “key” changed
But i want to keep only one instance in same time
i
you should use a singleton with a custom data structure then so you can retain a permanent reference to the structure while also allowing for your custom requirements of retention
r
A multiton keeps the instance according to key that you pass give to the instance function to retrieve your dependency. Thus, changing the argument will give you different instances, and using the same key multiple times will give you the same instance.