# Expire\_fragment with memcached

**URL:** <https://www.ruby-forum.com/t/expire-fragment-with-memcached/160658>\
**Category:** Rails\
**Created:** [February 18, 2009, 3:33pm UTC](https://www.ruby-forum.com/t/expire-fragment-with-memcached/160658 "2009-02-18T15:33:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![feustine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@feustine](https://www.ruby-forum.com/u/feustine)\
**Post date:** [February 18, 2009, 3:33pm UTC](https://www.ruby-forum.com/t/expire-fragment-with-memcached/160658/1 "2009-02-18T15:33:33Z")

</div>

Hello all,

We know that memcached or memcached-client doesn’t support regex… But  
It seems it doesn’t support expire\_fragment either 😕

I’m trying to use expire\_fragment with memcached as following :  
expire\_fragment(:controller =\> ‘home’, :action =\> :list\_posts)

But apparently it’s not supported by memcached :

RuntimeError (Not supported by Memcache):  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active\_support/cache/mem\_cache\_store.rb:79:in  
`delete_matched' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/caching/fragments.rb:128:in`expire\_fragment’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action\_controller/benchmarking.rb:26:in  
`benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/benchmarking.rb:37:in`silence’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action\_controller/benchmarking.rb:26:in  
`benchmark’

Would anyone know how to use expire\_fragment with memcached ?

Any help will be very appreciated !

Thank you !

---

<div class="post-metadata">

**Author:** ![feustine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@feustine](https://www.ruby-forum.com/u/feustine)\
**Post date:** [February 18, 2009, 3:42pm UTC](https://www.ruby-forum.com/t/expire-fragment-with-memcached/160658/2 "2009-02-18T15:42:59Z")

</div>

I’m using the timed fragment caching plugin (  
[GitHub - georgepalmer/timed\_fragment\_cache: timed\_fragment\_cache](http://github.com/georgepalmer/timed_fragment_cache/tree/master) )  
with memcached and i have no problems.

Have you configured your caching storage as memcached?

- 

Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)

On Wed, Feb 18, 2009 at 11:33 AM, Marie A.

---

<div class="post-metadata">

**Author:** ![feustine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@feustine](https://www.ruby-forum.com/u/feustine)\
**Post date:** [February 18, 2009, 3:55pm UTC](https://www.ruby-forum.com/t/expire-fragment-with-memcached/160658/3 "2009-02-18T15:55:22Z")

</div>

Well, you could try to use the one i’m using, also, you shoudn’t need  
to “delete” things from memcached, it does it by itself when it  
reaches it’s memory limit.

- 

Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)

On Wed, Feb 18, 2009 at 11:51 AM, Marie A.

---

<div class="post-metadata">

**Author:** ![feustine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@feustine](https://www.ruby-forum.com/u/feustine)\
**Post date:** [February 18, 2009, 3:51pm UTC](https://www.ruby-forum.com/t/expire-fragment-with-memcached/160658/4 "2009-02-18T15:51:56Z")

</div>

Of course…

I used to implement this plugin :  
[http://github.com/lacomartincik/memcache-store-with-delete\_matched/tree/master](http://github.com/lacomartincik/memcache-store-with-delete_matched/tree/master)

But after a while … When the memcached server starts to be filled up…  
The plugin make my whole application freeze for some reasons… My proc  
is used at 100% by dispatch.fcgi (I’m running on lightty). I don’t  
understand why… Without the plugin and with file store… Everything is  
fine and the proc used don’t go over 10%.

So I’m trying to come back to the basics and make it works without any  
plugins !

---

<div class="post-metadata">

**Author:** ![feustine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@feustine](https://www.ruby-forum.com/u/feustine)\
**Post date:** [February 18, 2009, 7:31pm UTC](https://www.ruby-forum.com/t/expire-fragment-with-memcached/160658/5 "2009-02-18T19:31:35Z")

</div>

MaurÃ­cio Linhares wrote:

> Well, you could try to use the one i’m using, also, you shoudn’t need  
> to “delete” things from memcached, it does it by itself when it  
> reaches it’s memory limit.
> 
> - 
> 
> Maurï¿½cio Linhares  
> [http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
> (en)
> 
> On Wed, Feb 18, 2009 at 11:51 AM, Marie A.

Ok it’s working thank you 🙂

Would you know how I can delete all the pages related to an action btw ?

I have in cache all the pages like :

/results/index?page=1  
/results/index?page=2  
/results/index?page=…  
/results/index?page=654

How could I delete all the cache for my controller results and my action  
index ?

expire\_fragments(:controller =\> ‘results’, :action =\> ‘index’) obviously  
doesn’t work !
