Re: What are some use case of memcache.cas, can it be used to handle set misses?

2016-06-24 Thread Nishant Varma
Also helpful if we have a detailed API documentation with error codes? Trying to read this but not so sure if I got it right https://github.com/memcached/memcached/wiki/BinaryProtocolRevamped On Friday, June 24, 2016 at 10:28:41 PM UTC+5:30, Nishant Varma wrote: > > Right, Thanks for clar

Re: What are some use case of memcache.cas, can it be used to handle set misses?

2016-06-24 Thread Nishant Varma
after a failing add, because if you read the > value, it was missing and the add fails (with the "already exist" error > code) it means the key was set in the meantime. > So you can read the value and make a cas to update it. > > Hope it helps > > 2016-06-24 14:12 GM

What are some use case of memcache.cas, can it be used to handle set misses?

2016-06-24 Thread Nishant Varma
http://neopythonic.blogspot.in/2011/08/compare-and-set-in-memcache.html, GVR talks about a use case of a simple counter. Generalizing that, 1) would it be fine to say you could use CAS when you need to modifying the data according to the latest state? For example counter, appending a list,

Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-10 Thread Nishant Varma
out your time. There is no hurry on this like I said I voluntarily trying to make it a bit better. Thanks, Nishant On Wednesday, June 8, 2016 at 11:58:00 PM UTC+5:30, Dormando wrote: > > > > On Tue, 7 Jun 2016, Nishant Varma wrote: > > > There was too much noise re

Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-07 Thread Nishant Varma
> if (memcli:add(key . "_lock", lock_timeout_time, my_admin_username)) { > [etc] > } else { > # lost the race, handle how you want > } > } else if (item.value == my_admin_username) { > # good to go for that future request > } > > Then when you're do

Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-07 Thread Nishant Varma
print "Being processed by %s" % user else: # But lost the race to find that. print "Processed by another user." def process(source): shutil.move(source, destination) # filename => source memcache.delete(filename) On Monday,

Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-06 Thread Nishant Varma
filename => source memcache.delete(filename) On Monday, June 6, 2016 at 7:07:21 PM UTC+5:30, Nishant Varma wrote: > > Enhanced it a bit to to check if the file is really present as well before > I proceed ... Btw this has to be done after obtaining the lock otherwise > agai

Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-06 Thread Nishant Varma
: return "Processed by another user." else: user = memcache.get(filename) return "%s is Processing" % user I guess this should cover our scenario. Do you have any thoughts? On Monday, June 6, 2016 at 5:20:28 PM UTC+5:30, Nishant

Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-04 Thread Nishant Varma
eed any more complication in my scenario? Would help if you can clarify. Thanks. Thanks, Nishant On Saturday, June 4, 2016 at 7:04:58 PM UTC+5:30, Nishant Varma wrote: > > I am reading > https://github.com/memcached/memcached/wiki/ProgrammingTricks#ghetto-central-locking, &

Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-04 Thread Nishant Varma
am sorry if I am repeating this, but I could not really relate the "fetching expensive item from Database" to my scenario which is why I even wrote a simple script to test the validity of the claim etc. Can you please let me know? On Saturday, June 4, 2016 at 6:42:35 PM UTC+5:30, N

Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-04 Thread Nishant Varma
seudocode in > the link I gave you several times in the issue. Please use it. > > Thanks, > -Dormando > > On Fri, 3 Jun 2016, Nishant Varma wrote: > > > Can anyone help me peer review this script > https://gist.github.com/varmanishant/0129286d41038cc21471652a6460a5

Re: Monitoring specific key patterns in Memcache server

2016-06-04 Thread Nishant Varma
data you need, however I insist *again* that you're > overengineering this. > > On Sat, 4 Jun 2016, Nishant Varma wrote: > > > Real time of offline solutions would be helpful. If I can profile in > background and query it later that is one option. However the only co

Re: Monitoring specific key patterns in Memcache server

2016-06-04 Thread Nishant Varma
:13:32 PM UTC+5:30, Nishant Varma wrote: > > I am trying to troubleshoot an issue which could happen because of get-set > race condition. I can monitor the entire memcache operations but I guess it > is going to be huge because its a small percentage of the DB itself, so I > need

Monitoring specific key patterns in Memcache server

2016-06-04 Thread Nishant Varma
I am trying to troubleshoot an issue which could happen because of get-set race condition. I can monitor the entire memcache operations but I guess it is going to be huge because its a small percentage of the DB itself, so I need to filter only the keys I am interested in. We have a namespacing

Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-04 Thread Nishant Varma
Can anyone help me peer review this script https://gist.github.com/varmanishant/0129286d41038cc21471652a6460a5ff that demonstrate potential problems with get set if it is used to implement distributed locking. I was suggested to modify from get set to add in this thread