Search in sources :

Example 1 with MemcacheEntry

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));
}
Also used : MemcacheEntry(com.hazelcast.internal.ascii.memcache.MemcacheEntry)

Example 2 with MemcacheEntry

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);
}
Also used : IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) RestValue(com.hazelcast.internal.ascii.rest.RestValue) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory) ConstructorFunction(com.hazelcast.internal.util.ConstructorFunction) MemcacheEntry(com.hazelcast.internal.ascii.memcache.MemcacheEntry)

Example 3 with MemcacheEntry

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));
}
Also used : MemcacheEntry(com.hazelcast.internal.ascii.memcache.MemcacheEntry)

Example 4 with MemcacheEntry

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));
}
Also used : MemcacheEntry(com.hazelcast.internal.ascii.memcache.MemcacheEntry)

Aggregations

MemcacheEntry (com.hazelcast.internal.ascii.memcache.MemcacheEntry)4 RestValue (com.hazelcast.internal.ascii.rest.RestValue)1 ArrayDataSerializableFactory (com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory)1 ConstructorFunction (com.hazelcast.internal.util.ConstructorFunction)1 IdentifiedDataSerializable (com.hazelcast.nio.serialization.IdentifiedDataSerializable)1