I have several Ruby objects with unique identifiers that I now cache in Hash. When an identifier is assigned to an object, it goes into a hash. The cache is complete, i.e. Each object with an identifier that exists in the Ruby area must also be in the cache.
However, I had problems finding a way to remove objects from the cache after they disappeared from all other areas. This, of course, is because the objects contained in the cache will not collect garbage.
Are there any approaches to this problem? The documentation for the WeakRefproposed class WeakHash, but it does not seem acceptable for practical use, although it is very close to what I think I need for my project.
source
share