Forum OpenACS Development: Re: caching ns_sets

Collapse
4: Re: caching ns_sets (response to 3)
Posted by Jeff Davis on
You can't cache ns_sets with ns_cache even with the -persist flag. ns_sets are thread local and the ns_cache used by util_memoize is not. Even if you use a thread local cache there is no way to free the ns_set if the handle gets flushed. And besides, you don't want to cache this on a per thread basis. Anyway, I think unless there is some really good reason to use ns_sets (and I don't see one having looked at how this is being used), I think you would be better off caching a list of lists anyway.
Collapse
7: Re: caching ns_sets (response to 4)
Posted by Dan Wickstrom on
Jeff, you're statement about ns_sets is slightly incorrect.  ns_sets created with the -persist flag are not thread local.  The handle for a ns_set created with the -persist flag is stored in a static hashtable that is globally accessible.  Access to persistant sets is protected by a global mutex, so there shouldn't be a problem with accessing it from multiple threads.
Collapse
9: Re: caching ns_sets (response to 7)
Posted by Jeff Davis on
My mistake.  Although I still think it's better to put the data
into a list and ns_cache for that although I guess if
it is indeed persistent you could put the handle in an
nsv or in an unlimited size/time ns_cache (keeping in
mind that there would then be no mechanism to flush
the cache other than by hand).