Can memcached be used for locking?
memcached can be used for a caching static data which reduces database lookup and typically does memcached.get(id) and memcached.set(id) . However is it fine to use this for locking mechanisms? Does memcache.set and memcached.get always give the data if it is present or will it just return None if the request is taking too much time? I want to avoid concurrent access to a particular resource identified by a id and I use this logic: def access(id): if memcache.get(id): return access else: memcache.set(id) return true If any user tries to access that resource, if memcache.get(id) = username