use of com.hazelcast.internal.ascii.memcache.MemcacheEntry in project hazelcast by hazelcast.
the class MemcacheTest method testSetGetDelete_WithIMap.
private void testSetGetDelete_WithIMap(String mapName, String prefix) throws Exception {
String key = "key";
String value = "value";
String value2 = "value2";
IMap<String, Object> map = instance.getMap(mapName);
map.put(key, value);
assertEquals(value, client.get(prefix + key));
client.set(prefix + key, 0, value2).get();
MemcacheEntry memcacheEntry = (MemcacheEntry) map.get(key);
MemcacheEntry expectedEntry = new MemcacheEntry(prefix + key, value2.getBytes(), 0);
assertEquals(expectedEntry, memcacheEntry);
assertEquals(prefix + key, memcacheEntry.getKey());
client.delete(prefix + key).get();
assertNull(client.get(prefix + key));
assertNull(map.get(key));
}
use of com.hazelcast.internal.ascii.memcache.MemcacheEntry in project hazelcast by hazelcast.
the class TextProtocolsDataSerializerHook method createFactory.
@Override
public DataSerializableFactory createFactory() {
ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
constructors[MEMCACHE_ENTRY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MemcacheEntry();
}
};
constructors[REST_VALUE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new RestValue();
}
};
return new ArrayDataSerializableFactory(constructors);
}
use of com.hazelcast.internal.ascii.memcache.MemcacheEntry in project hazelcast by hazelcast.
the class MemcachedTest method testSetGetDelete_WithIMap.
private void testSetGetDelete_WithIMap(String mapName, String prefix) throws Exception {
String key = "key";
String value = "value";
String value2 = "value2";
IMap<String, Object> map = instance.getMap(mapName);
map.put(key, value);
assertEquals(value, client.get(prefix + key));
client.set(prefix + key, 0, value2).get();
MemcacheEntry memcacheEntry = (MemcacheEntry) map.get(key);
MemcacheEntry expectedEntry = new MemcacheEntry(prefix + key, value2.getBytes(), 0);
assertEquals(expectedEntry, memcacheEntry);
assertEquals(prefix + key, memcacheEntry.getKey());
client.delete(prefix + key).get();
assertNull(client.get(prefix + key));
assertNull(map.get(key));
}
use of com.hazelcast.internal.ascii.memcache.MemcacheEntry in project hazelcast by hazelcast.
the class MemcachedRawTcpTest method testSetGetDelete_WithIMap.
private void testSetGetDelete_WithIMap(String mapName, String prefix) throws Exception {
String key = "key";
String value = "value";
String value2 = "value2";
IMap<String, Object> map = instance.getMap(mapName);
map.put(key, value);
sendLine(String.format("get %s", prefix + key));
assertEquals(String.format("VALUE %s 0 %d", prefix + key, value.length()), receiveLine());
assertEquals(value, receiveLine());
assertEquals("END", receiveLine());
sendLine(String.format("set %s 123 0 %d", prefix + key, value2.length()));
sendLine(value2);
assertEquals("STORED", receiveLine());
MemcacheEntry memcacheEntry = (MemcacheEntry) map.get(key);
MemcacheEntry expectedEntry = new MemcacheEntry(prefix + key, value2.getBytes(), 123);
assertEquals(expectedEntry, memcacheEntry);
assertEquals(prefix + key, memcacheEntry.getKey());
sendLine(String.format("delete %s", prefix + key));
assertEquals("DELETED", receiveLine());
assertNull(map.get(key));
}
Aggregations