lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Sun, Nov 01, 2009 at 08:33:17AM -0800, Mark Hamburg wrote:
> If you can attach data to the cached objects, then build the cache
> using fully weak tables and have the cached objects hold references
> to the tables in the chain leading to them.

Thanks Mark, this is a nice idea. I won't in general be able to rely on
adding data to the cached objects. But maybe there's a way to do this
with objects wrapping the cached objects?

The problem is, if the cache's clients are just getting the cached
objects, without their wrappers, and the wrapper is what holds the refs that
keep the cache tables from being gc'd, what holds the refs to the
wrappers? In your suggestion, the cached objects themselves hold those

Probably the best way to do something like this using wrappers is
what I ended up posting last night.