# Using Memcache client

**URL:** <https://www.ruby-forum.com/t/using-memcache-client/69348>\
**Category:** Ruby\
**Created:** [September 20, 2006, 1:20pm UTC](https://www.ruby-forum.com/t/using-memcache-client/69348 "2006-09-20T13:20:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnufied](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ea666f/32.png) [@gnufied](https://www.ruby-forum.com/u/gnufied)\
**Post date:** [September 20, 2006, 1:20pm UTC](https://www.ruby-forum.com/t/using-memcache-client/69348/1 "2006-09-20T13:20:29Z")

</div>

Some some simple/[stupid|smart] questions about memcache.

I am using the wrapper written by Eric H…

1. Is it thread safe? By that I mean…lets say, I have one thread  
that writes to it and the other reads from it. How will it behave  
then. Please note that, only one thread will be used to write to  
it…rest all will just read. I see…mutex.synchronize in the code…so  
should be theoretically thread safe.

2. I start a program, connect to the server using MemCache.new on a  
new namespace and do some data manipulation. Then i don’t need to  
close the connection, right? Do i need to delete the keys that i put?  
or they will expire.

Here…I am using it outside rails domain.

---

<div class="post-metadata">

**Author:** ![gnufied](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ea666f/32.png) [@gnufied](https://www.ruby-forum.com/u/gnufied)\
**Post date:** [September 21, 2006, 7:34am UTC](https://www.ruby-forum.com/t/using-memcache-client/69348/2 "2006-09-21T07:34:47Z")

</div>

On Sep 20, 2006, at 4:18 AM, hemant wrote:

> Some some simple/[stupid|smart] questions about memcache.
> 
> I am using the wrapper written by Eric H…
> 
> 1. Is it thread safe? By that I mean…lets say, I have one thread  
> that writes to it and the other reads from it. How will it behave  
> then. Please note that, only one thread will be used to write to  
> it…rest all will just read. I see…mutex.synchronize in the code…so  
> should be theoretically thread safe.

Some of the documentation lies, but, see: ri MemCache.new

> 1. I start a program, connect to the server using MemCache.new on a  
> new namespace and do some data manipulation. Then i don’t need to  
> close the connection, right? Do i need to delete the keys that i put?  
> or they will expire.

Don’t worry about it, memcached will take care of the stored data for  
you. Ruby’s GC will take care of closing connections for you.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)
