Comments (8)
Pardon my ignorance but it seems "simple" to implement, at least for the
mutate() call -- i.e. not for mutateWithDefault().
It seems all that is needed is a asyncMutate() function:
private Future<Long> asyncMutate(Mutator m, String key, int by, long def, int exp)
throws OperationTimeoutException {
final CountDownLatch latch=new CountDownLatch(1);
final OperationFuture<Long> rv=new OperationFuture<Long>(latch,
operationTimeout);
addOp(key, opFact.mutate(m, key, by, def, exp, new OperationCallback() {
public void receivedStatus(OperationStatus s) {
// XXX: Potential abstraction leak.
// The handling of incr/decr in the binary protocol
// Allows us to avoid string processing.
rv.set(new Long(s.isSuccess()?s.getMessage():"-1"));
}
public void complete() {
latch.countDown();
}}));
return rv;
}
Then we can trivially add asyncIncr() and asyncDecr():
public Future<Long> asynIncr(String key, int by) throws OperationTimeoutException {
return asyncMutate(Mutator.incr, key, by, 0, -1);
}
public Future<Long> asyncDecr(String key, int by) throws OperationTimeoutException {
return asyncMutate(Mutator.decr, key, by, 0, -1);
}
Of course mutate() itself would be implemented in terms of asyncMutate():
private long mutate(Mutator m, String key, int by, long def, int exp)
throws OperationTimeoutException {
try
{
return asyncMutate(m, key, by, def, exp).get(operationTimeout,
TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted waiting for value", e);
} catch (ExecutionException e) {
throw new RuntimeException("Exception waiting for value", e);
} catch (TimeoutException e) {
throw new OperationTimeoutException("Timeout waiting for value", e);
}
}
Now asyncMutateWithDefault() that's a bit more complicated.
No?
Original comment by [email protected]
on 28 Aug 2008 at 7:18
from spymemcached.
You're right, it's the with-default that's the issue. That's the only way it
makes
sense to use incr/decr to me.
I implemented it in the binary protocol in such a way that it can be done in a
single
request, but before that, the multiple round trip thing had to happen.
Original comment by [email protected]
on 29 Aug 2008 at 6:58
from spymemcached.
This is implemented as of 6e2dbb3aac1a2980bc2252670467e219d803a3d8 -- Thanks to
Kristian Eide
Original comment by [email protected]
on 2 Oct 2008 at 7:04
- Changed state: Fixed
- Added labels: Milestone-Release2.2
from spymemcached.
I was clearly out of my head when I closed this bug. Apologies.
Original comment by [email protected]
on 10 Oct 2008 at 5:06
- Changed state: Accepted
from spymemcached.
nbrachet: I'd like to credit you for this change. Can you send me a name and
email
address to [email protected]?
Original comment by [email protected]
on 18 Oct 2008 at 11:44
from spymemcached.
This is fixed in my async-mutate branch. I'll apply it to stable either once I
get
information to credit nbrachet, or early next week.
Original comment by [email protected]
on 18 Oct 2008 at 11:56
from spymemcached.
Original comment by [email protected]
on 18 Oct 2008 at 11:57
- Changed state: Fixed
from spymemcached.
pushed
Original comment by [email protected]
on 19 Oct 2008 at 12:08
from spymemcached.
Related Issues (20)
- State the dependencies in the pom file HOT 5
- Multhreaded implementation with SASL support not working. HOT 1
- Operation class is used in un-threadsafe, unsynchronized manner. HOT 4
- Inside TCPMemcachedNodeImpl, use direct buffers HOT 4
- Stability problems in async I/O HOT 4
- assertion failure during ConsistentHashingTest HOT 1
- incr/decr parameter "by" should be a long, not an int HOT 9
- Zlib encoding/binary access HOT 3
- getBulk() logs a warning when no keys are in the cache HOT 3
- bug in OperationImpl HOT 6
- get(long timeout, TimeUnit unit) may take longer than given timeout HOT 3
- IllegalArgumentException after Switching from SpyMemcached 2.7 to 2.7.1 HOT 2
- "unl" unlock operation is not implemented on MembaseClient HOT 9
- 2.7.1 jar for download corrupt? HOT 5
- Callback support HOT 11
- Get canceled HOT 5
- CAS operation fails due to client sign-extending the CAS value HOT 1
- warning for "handling node for operation is not set" if any server is down HOT 4
- javadoc warnings from tap and vbucket classes HOT 3
- CASMutator removes expiry on mutated items
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 spymemcached.