Hi Henrik,
Thanks for the reply.

I put the lock around the gets and sets becoz of my requirement. Each
set in cache is manipulated on existing data and then set so to keep
integrity i must have to put lock so that no other process could
acquire the lock and destroy the integrity.

I do have persistent storage as DB but our First point of delivery to
page is cache and not DB, if cache fails then it will be handled by
code to fetch from DB.

But as far as our Cache server is Up, I have to make sure that data
integrity is not Lost!!

and becoz to acquire Lock i have implemented Strict locking i.e. Dont
proceed until lock is acquired, so in that case, i need that status. I
m giving pseudo -code for lock then it will be more clear,

pseudo_lock = "lock_".<key>
IS_LOCK = false
while ( 1 ) { /loop indefinitely
 if ( get_pseudo_lock_success ) {
     IS_LOCK = true
     break;
 }
usleep // wait for microsecond
}

if ( IS_LOCK) //Then only proceed
else //do DB Opearation



Now in this scenario, if dont know the status of the server my loop
will be forever !!

Waiting for a favourable reply.


Regards,
Sagar





On Jan 29, 2:16 pm, Henrik Schröder <[email protected]> wrote:
> Why do you need to put a lock around your memcached code? All memcached
> operations are atomic in themselves.
>
> Why do you need to know the status of a server before you do a memcached
> operation? Doesn't your client library return whether a set operation
> succeeded or failed?
>
> They way it's supposed to work is that you should never really care about
> individual servers. You do your sets and gets, each item goes to some
> server, and when you get an item you may or may not get it back. Maybe it
> expired. Maybe the server it went to was down. Either case, it's a cache,
> and your application should be able to handle cache misses.
>
> /Henrik
>
> On Fri, Jan 29, 2010 at 06:03, nEosAg <[email protected]> wrote:
> > Hi,
>
> > I am using PHP Memcache client library  and NOT Memcached library.
>
> > "How can i know if Memcache server is Running except getServerStatus()
> > method of PHP client Memcache Library??"
>
> > Why i am saying not using getServerStatus() call is because that
> > method works only with individual server but at runtime Code will
> > never knew which server has been chosen by Hash policy, so we are
> > having pool of servers all the time.
>
> > I need to check this is because as i need to do Locking to achieve
> > atomicity and integrity,  in that case i have wait for infinite loop
> > till i get lock, so in that case i must know that status of server or
> > my code will go in indefinite loop if memcache server goes down.
>
> > Please guide me. Waiting for a favourable reply.
>
> > Regards,
> > Sagar

Reply via email to