hi, Trond.  It means I can  create many identical memcached_st instances in 
advance and push them into a pool. Then, I can pop a memcached_st instance when 
needed. How can I use the pool efficiently? Furthermore, I have another 
problem. How can I restrict some fixed ips to access the memcached servers 
except using iptables?  Because the iptables command needs root permission to 
execute. Thank you for your reply.
--- 11年8月12日,周五, Trond Norbye <trond.nor...@gmail.com> 写道:


发件人: Trond Norbye <trond.nor...@gmail.com>
主题: Re: Can anyone tell me the benifit of libmemcached pool?
收件人: memcached@googlegroups.com
日期: 2011年8月12日,周五,下午1:36





On Fri, Aug 12, 2011 at 3:17 AM, 然 安 <nuanran...@yahoo.com.cn> wrote:






Hi, Trond. I have read the man page for  the function memcached_pool_pop(), but 
I still don't know what's the meaning of the parameter bool block. 
 

If you create a pool with 5 instances and your code tries to pop 6 instances 
out of the pool. if you set the block parameter to true, the 6th call to pop 
will block until someone push an instance back into the pool.


 





I think the libmemcached uses the pool to store the memcached_st, and 
memcached_st keeps a connection with each server in the configuration 
string.But, can multiple memcached_st be stored in the same pool? Can a 
memcached_st be poped multiple times? Does it mean a pool can only keep a long 
cnnection with each server in the configuration string. 

The pool is used to store memcached_st instances, and you can push and pop the 
instances as many times as you like. The idea of the pool is that instead of 
doing:

my_little_function_who_needs_memcached() {
   create memcached_st
   call a libemcached function
   destroy memcached_st
}

you would do something like:

my_little_function_who_needs_memcached(pool) {
   grab instance from the pool
   call a libemcached function
   push it back to the pool
}

Trond






 





          Thank you for your reply.
            
 
--- 11年8月11日,周四, Trond Norbye <trond.nor...@gmail.com> 写道:



发件人: Trond Norbye <trond.nor...@gmail.com>

主题: Re: Can anyone tell me the benifit of libmemcached pool?
收件人: memcached@googlegroups.com
日期: 2011年8月11日,周四,下午6:48





make install will also install a manual page for the functions.. 


Cheers,

Trond



On Thu, Aug 11, 2011 at 10:29 AM, 然 安 <nuanran...@yahoo.com.cn> wrote:







Hi, if I define a memcached pool like this:
memcached_pool_st* pool=memcached_pool("--SERVER=ip:port",config_length);
can I pop memcached_st multiple times use this pool? like:
memcached_st *memc1 = memcached_pool_pop(pool,false,&rc);
memcached_st *memc2 = memcached_pool_pop(pool,false,&rc);
 
can anywhere I find the detailed explanation of these functions, including the 
returen value and parameters?
thank you very much!
--- 11年7月30日,周六, Brian Aker <br...@tangent.org> 写道:


发件人: Brian Aker <br...@tangent.org> 

主题: Re: Can anyone tell me the benifit of libmemcached pool?
收件人: memcached@googlegroups.com
日期: 2011年7月30日,周六,上午7:02 





BTW it works out well for non-threaded applications as well, since it is a 
pretty easy API to use for just caching the connection between page calls (i.e. 
and application running in Apache)

On Jul 29, 2011, at 12:45 PM, Trond Norbye wrote:

> You would use a pool of libmemcached instances in your multithreaded 
> application to avoid initiating, connect, disconnect and destroy each time 
> one of the threads wants to send a request to the memcached cluster. Instead 
> you can get an instance from the pool, use it, and put it back in the pool 
> for other threads to use..
> 
> Cheers
> 
> Trond
> 




-- 
Trond Norbye




-- 
Trond Norbye

Reply via email to