# Memcached - multiple puts and deletes?

**URL:** <https://www.ruby-forum.com/t/memcached-multiple-puts-and-deletes/92028>\
**Category:** Rails\
**Created:** [April 14, 2007, 9:47pm UTC](https://www.ruby-forum.com/t/memcached-multiple-puts-and-deletes/92028 "2007-04-14T21:47:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![giantcranes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@giantcranes](https://www.ruby-forum.com/u/giantcranes)\
**Post date:** [April 14, 2007, 9:47pm UTC](https://www.ruby-forum.com/t/memcached-multiple-puts-and-deletes/92028/1 "2007-04-14T21:47:39Z")

</div>

Hi,

I have recently started using memcached to store my ‘Vehicle’ models  
which are expensive to construct (have may related models). I am also  
using memcache-client to fetch these models, sometimes many at a time  
using ‘get\_multi’.

In the docs  
([http://dev.robotcoop.com/Libraries/memcache-client/index.html](http://dev.robotcoop.com/Libraries/memcache-client/index.html)) there  
doesn’t seem to be any support for multiple puts and deletes.

Are there any alternative memcached clients which support multiple puts  
and deletes? Has anyone implemented support for this in their own  
applications?

Any pointers or tips would be much appreciated.

Thanks,  
GiantCranes

---

<div class="post-metadata">

**Author:** ![giantcranes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@giantcranes](https://www.ruby-forum.com/u/giantcranes)\
**Post date:** [April 14, 2007, 11:22pm UTC](https://www.ruby-forum.com/t/memcached-multiple-puts-and-deletes/92028/2 "2007-04-14T23:22:57Z")

</div>

On 4/14/07, Giant C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have recently started using memcached to store my ‘Vehicle’ models  
> which are expensive to construct (have may related models). I am also  
> using memcache-client to fetch these models, sometimes many at a time  
> using ‘get\_multi’.
> 
> In the docs  
> ([http://dev.robotcoop.com/Libraries/memcache-client/index.html](http://dev.robotcoop.com/Libraries/memcache-client/index.html)) there  
> doesn’t seem to be any support for multiple puts and deletes.

memcached’s protocol does not support multi-key put or delete.

> Are there any alternative memcached clients which support multiple puts  
> and deletes? Has anyone implemented support for this in their own  
> applications?

If any client supports multi-key put or delete, it’ll be implemented  
at the app layer.

Like this:

def delete\_multi(\*keys)  
keys.each { |key| delete key }  
end

The multi get is implemented in memcached itself.

–  
Chris W.

> **[err.the\_blog](http://errtheblog.com)**
>
> Err the Blog: Ruby and Rails from the front.

---

<div class="post-metadata">

**Author:** ![giantcranes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@giantcranes](https://www.ruby-forum.com/u/giantcranes)\
**Post date:** [April 14, 2007, 11:54pm UTC](https://www.ruby-forum.com/t/memcached-multiple-puts-and-deletes/92028/3 "2007-04-14T23:54:55Z")

</div>

> memcached’s protocol does not support multi-key put or delete.
> 
> > Are there any alternative memcached clients which support multiple puts  
> > and deletes? Has anyone implemented support for this in their own  
> > applications?
> 
> If any client supports multi-key put or delete, it’ll be implemented  
> at the app layer.
> 
> Like this:
> 
> def delete\_multi(\*keys)  
> keys.each { |key| delete key }  
> end
> 
> The multi get is implemented in memcached itself.

Thanks for the info, I suppose I will have to do the deletes in a  
background thread.
