# Memcached - clear all keys matching a pattern?

**URL:** <https://www.ruby-forum.com/t/memcached-clear-all-keys-matching-a-pattern/153303>\
**Category:** Ruby\
**Created:** [November 14, 2008, 4:58pm UTC](https://www.ruby-forum.com/t/memcached-clear-all-keys-matching-a-pattern/153303 "2008-11-14T16:58:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [November 14, 2008, 4:58pm UTC](https://www.ruby-forum.com/t/memcached-clear-all-keys-matching-a-pattern/153303/1 "2008-11-14T16:58:25Z")

</div>

I have some pages that serve up a massive tree of html, with a few  
different varieties used on different pages. Generating the html is  
quite intensive so I use memcached to store the different flavours,  
generating a different key for each flavour.

When the tree contents change, i need to clear these keys out of  
memcached so they will be re-generated next time someone goes to the  
pages. So far i’ve been flushing everything with CACHE.flush  
(CACHE.flush\_all locally) but it would be better to just flush the  
relevant keys. Since the key names are also subject to change, but all  
contain the fragment “property\_tree” in their names, ideally i would  
like to drop all keys matching against /property\_tree/ and leave the  
rest.

Is there a way to do this? I can’t see any way of getting memcached to  
tell me all of it’s saved keys.

thanks  
max
