Comments (1)
Hello @exts
Thank you very much for your comment. I read the link you provided, and it turned out this is about memcached text protocol. This library is based on the "new" binary protocol, which is described here: https://github.com/memcached/memcached/wiki/BinaryProtocolRevamped
As you can see, there is no dedicated CAS command in this protocol. Instead, there is a "version" of a value, which is returned as a result of GET command. In this library is it implemented as get_with_version method. Then, you can pass this version to set method. If the passed version differs from the actual version in memcached, the client will raise BadVersionException. I think it is in accordance with the protocol description:
If the Data Version Check (CAS) is nonzero, the requested operation MUST only succeed if the item exists and has a CAS value identical to the provided value.
Therefore, I assume that if you want to implement compare and set in your application, you should do something like this:
- using get_with_version get a key value and its version (cas token) , and store them somewhere
- when you want to update the value, call set and pass the version among other parameters
- check for BadVersionException; if it is thrown, do something that makes sense for your app
This library is just an a thin wrapper around memcached protocol command. Therefore, I was not sure if it was a good idea to implement some additional CAS logic there. On the other hand, some other clients (dalli, for example) implement cas method. So, it may be a good idea to provide something like this here.
from crystal-memcached.
Related Issues (12)
- DELETE ME
- Implement key hashing
- Implement Storing Binary Data
- Implement value compression/decompression
- Implement Serialization of Data Structures
- Proper timeouts handling
- Using memcached client with large values truncates response HOT 5
- Tag New Release HOT 2
- How to configure or set options?
- The client is extremelly slow HOT 3
- Fails with large values in memcached HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crystal-memcached.