Rationalize the instantiation of caches
The instantiation of the LRUDict
and LRUDictTransaction
are done in multiple places but also using dict.setdefault
which instantiate a LRUDict
even if it is not needed.
It will be better to use the default_factory
for that. But some cases require to know the key to instantiate the next LRUDict
so we could have a new parameter default_factory_with_key
to pass the key.
Finally the Transaction.cache
should also be limited in size.