Skip to content

Commit

Permalink
Part 7: fixes brianfrankcooper#2 - Update Memcached client
Browse files Browse the repository at this point in the history
  • Loading branch information
lyubent committed Jul 14, 2014
1 parent 9fddc22 commit 1c9dd11
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ public void init() throws DBException {
protected abstract MemcachedClient createMemcachedClient() throws Exception;

@Override
public int readOne(String table, String key, String field, Map<String,ByteIterator> result) {

return read(table, key, Collections.singleton(field), result);
}

@Override
public int readAll(String table, String key, Map<String,ByteIterator> result) {
return read(table, key, null, result);
}

public int read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
try {
GetFuture<Object> future = client.asyncGet(createQualifiedKey(table, key));
Expand All @@ -84,12 +94,28 @@ public int read(String table, String key, Set<String> fields, Map<String, ByteIt
}

@Override
public int scan(String table, String startKey, int limit, Set<String> fields, List<Map<String, ByteIterator>> result) {
public int scanAll(String table, String startkey, int recordcount, List<Map<String, ByteIterator>> result) {
throw new IllegalStateException("Range scan is not supported");
}

@Override
public int update(String table, String key, Map<String, ByteIterator> values) {
public int scanOne(String table, String startkey, int recordcount, String field, List<Map<String, ByteIterator>> result) {
throw new IllegalStateException("Range scan is not supported");
}

@Override
public int updateOne(String table, String key, String field, ByteIterator value) {

return update(table, key, Collections.singletonMap(field, value));
}

@Override
public int updateAll(String table, String key, Map<String,ByteIterator> values) {

return update(table, key, values);
}

public int update(String table, String key, Map<String,ByteIterator> values) {
key = createQualifiedKey(table, key);
try {
OperationFuture<Boolean> future = client.replace(key, objectExpirationTime, toJson(values));
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<!--<module>accumulo</module>-->
<module>dynamodb</module>
<module>jdbc</module>
<!--<module>memcached</module>-->
<module>memcached</module>
<module>mongodb</module>
<module>distribution</module>
</modules>
Expand Down

0 comments on commit 1c9dd11

Please sign in to comment.