Can I create multi hash table?
pault12345 at yahoo.com
Wed Sep 27 15:35:02 UTC 2006
Want multiple dimensions == use multiple 'key salts'.
--- Anatol Pomozov <anatol.pomozov at gmail.com> wrote:
> Hi, all.
> I would try to the develop idea of multidimensional
> hash that Mingqi started.
> The last month idea of using Memcached for caching
> becomes very
> popular in RubyOnRails community. You could find
> several recipes and
> articles how to use MemCached with RoR.
> And I would say that memcached hepls a lot with
> There is no problems with objects that uniquely
> defined by key. For
> example models
> 'class User' defined by its id and we store it in
> memcached with key
> There are no probls.
> Another story with view fragments caching
> Lets imagine example - on web page we have a list of
> Content of this list depends on:
> * user - different users have different price
> algorithms, some of the users have discounts.
> * language that user uses. Product names shown in
> language that user
> choose. Something like we have here
> * producer. Different producers have different
> list of products and
> different prices, so we need to cache this fragments
> for each producer
> * ...
> I would like to cache this fragment cause price
> calculation is very
> expensive operation.
> So to cache we need to use complex key like
> Problem goes when we need to expire (remove from
> cache) subset of the records.
> Lets imagine that some user A get 10% discount to
> all products. We
> need to remove from cache ALL fragments that match
> How to do it with Memcached?
> There are also possible a lot of other cases. Like
> * We change Russian translation and would like to
> remove ALL
> fragments for Russian language.
> * Producer changed price to its products for user
> C - we need to
> remove all fragments with this producerID and user =
> On 9/27/06, Steven Grimm <sgrimm at facebook.com>
> > You have a couple options. If flushing all person
> data is a very infrequent
> > operation, you can do a "flush_all" command, which
> will flush the entire
> > cache, including all your product data. That's by
> far the most efficient (on
> > the memcached side, anyway) but obviously it means
> your application will
> > have to repopulate the whole cache, not just the
> person data.
> > Alternately, if you need to flush all your person
> data often, you can add
> > another prefix or suffix to your keys: a version
> number. When you want to
> > flush the person data, just increase the version
> number you append to all
> > your person keys. The old values will still be in
> the cache, but you will
> > never look them up and they will eventually fall
> out of the cache because of
> > the LRU algorithm.
> > There is no way to perform bulk operations on a
> subset of the values in the
> > cache.
> > If you tell us a little more about why you want
> to flush your person data,
> > one of us can probably offer some alternate
> approaches. Assuming, that is,
> > that one of the two suggestions above isn't
> suitable for you.
> anatol (http://feeds.feedburner.com/apomozov-eng)
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
More information about the memcached