Can I create multi hash table?

Paul T pault12345 at yahoo.com
Wed Sep 27 15:35:02 UTC 2006


http://lists.danga.com/pipermail/memcached/2006-July/002551.html
http://lists.danga.com/pipermail/memcached/2006-July/thread.html#2544

Want multiple dimensions == use multiple 'key salts'.

Rgds.Paul.

--- 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
> caching.
> 
> 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
> model/user/id
> There are no probls.
> 
> Another story with view fragments caching
>
http://rubyonrails.org/api/classes/ActionController/Caching/Fragments.html
> Lets imagine example - on web page we have a list of
> products.
> Content of this list depends on:
>   * user - different users have different price
> calculation
> algorithms, some of the users have discounts.
>   * language that user uses. Product names shown in
> language that user
> choose. Something like we have here
> http://www.novagora.hu/
>   * producer. Different producers have different
> list of products and
> different prices, so we need to cache this fragments
> for each producer
> separately.
>   * ...
> 
> I would like to cache this fragment cause price
> calculation is very
> expensive operation.
> 
> So to cache we need to use complex key like
> /fragment/pricelist/USERID/PRODUCERID/LANGUAGE
> 
> right?
> 
> 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
> Regexp
> 
> /fragment/pricelist/A_USER.ID/.*/.*
> 
> 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.
>     
>
remove_from_cache_by_key('/fragment/pricelist/.*/.*/ru')
>   * Producer changed price to its products for user
> C - we need to
> remove all fragments with this producerID and user =
> C
> 
> On 9/27/06, Steven Grimm <sgrimm at facebook.com>
> wrote:
> >  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 
http://mail.yahoo.com 


More information about the memcached mailing list