On 27 November 2012 07:56, Denis Kudriashov <dionisiydk@gmail.com> wrote:
Hello.
I want implement cache for proxy objects. I need some kind of dictionary which I can request for proxy of actual object. And any user of actual objects will work with same instances of proxies. And every proxy object has reference to actual object.
Obvious solution is basic dictionary with actual objects as keys and proxy-objects as values. But next I want my dictionary be week. And when nobody uses actual object it should be garbaged and my cache of proxies should be cleaned from unused proxies/actuals.
Is it possible to implement such cache? And how it can be done?
You could take a look at the WeakDictionary that ships in a standard Squeak image, if there isn't already one lying around in Pharo. There are several classes using weak references. frank
Best regards, Denis