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)
- NPE happening in TCPMemcachedNodeImpl.fillWriteBuffer under heavy load
- Memory Leak in LinkedBlockingQueue in AsciiMemcachedNodeImpl/TCPMemcachedNodeImpl
- JVM crashed always with Memcached IO over
- NPE
- Allow to configure MAX_CLONE_COUNT parameter
- CASMutator.cas should throw typed exception
- read/write queues are not being cleared incase of faulty server:port, proposed a fix
- How to get more two values using get(key) API ?
- Broken link on "Project Home"
- Memcache sets taking unusually long time HOT 1
- Unable to read Binary data (C Struct) from Memcache HOT 7
- MemcacheClient with SerializingTranscoder isn't thread safe
- Very big performance issue with large numbers of asyncGets
- java.lang.AssertionError: Unknown line type: STORED HOT 1
- can spymemcached cause race condition?
- Missing CAS API (With exp. time and without Transcoder) HOT 1
- Booleans contained in Clojure maps deserialized as new instances of java.lang.Boolean - breaks "if" HOT 1
- Client never connects with small timeout (auth problem)
- getBulk() doesn't use FailureMode HOT 3
- Set request fails after restarting the server HOT 1
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.