Note, this documentation and functionality are still under development and may not necessarily match what you see here.
Through an extension, Membase has a feature allowing individual clients to be sure they have exclusive access to an item for a period of time. This is not yet supported functionality, and should be considered experimental.
The getl command takes two arguments a key and an expiration time. If no expiration time is set then the default expiration is 15 seconds. getl also has a maximum expiration time of 29 seconds so any expiration time greater than 29 seconds is automatically changed to 29 seconds. Below are four use cases that describe how getl works. In these use cases we use the set operation as an example of an operation that is blocked when a getl is applied to a key. Note however that the operations delete, incr, etc. also will be blocked by getl.
1. Timeout locks the key for the specified time
Set a key
Perform a getl on the key with a timeout of 15 seconds
Attempt to set the key with a new value
Should get "EXISTS"
Perform a get on the key to verify the key has its original value
Wait 15 seconds
Attempt to set the key with a new value
Perform a get on the key to verify the key has the new value
2. CAS unlocks the key before the timeout
Set a key
Perform a getl on the key with a timeout of 15 seconds
Attempt to cas the key with a using the appropriate cas id
Perform a get on the key to verify the key has its new value
Attempt to set the key with a new value
Perform a get on the key to verify the key has the new value
3. GETL fails against a locked key
Set a key
Perform a getl on the key with a timeout of 15 seconds
Perform a getl without a timeout
Should get "LOCK_ERROR"
4. GETL honors an old timeout
Set a key
Perform a getl on the key with a timeout of 3600 seconds (Will be set to 29 seconds by Membase)
Perform a getl on the key with a timeout of 5 seconds
Wait 5 seconds
Perform a set on the key with a new value
Set should fail with "EXISTS"
Wait 24 seconds
Perform a set on the key with a new value
Set should pass
Perform a get on the key to verify the key has the new value