Package net.rubyeye.xmemcached.transcoders

Examples of net.rubyeye.xmemcached.transcoders.StringTranscoder


  public void testSet() throws Exception {
    assertTrue(memcachedClient.set("name", 0, "dennis"));
    assertEquals("dennis", memcachedClient.get("name", 2000));

    assertTrue(memcachedClient.set("name", 1, "zhuang",
        new StringTranscoder()));
    assertEquals("zhuang", memcachedClient.get("name", 2000));
    Thread.sleep(2000);
    // expired
    assertNull(memcachedClient.get("zhuang"));
View Full Code Here


  public void testStoreNoReply() throws Exception {
    memcachedClient.replaceWithNoReply("name", 0, 1);
    assertNull(memcachedClient.get("name"));

    memcachedClient.setWithNoReply("name", 1, "dennis",
        new StringTranscoder());
    assertEquals("dennis", memcachedClient.get("name"));
    Thread.sleep(2000);
    assertNull(memcachedClient.get("name"));

    memcachedClient.setWithNoReply("name", 0, "dennis",
        new StringTranscoder());
    memcachedClient.appendWithNoReply("name", " zhuang");
    memcachedClient.prependWithNoReply("name", "hello ");
    assertEquals("hello dennis zhuang", memcachedClient.get("name"));

    memcachedClient.addWithNoReply("name", 0, "test",
        new StringTranscoder());
    assertEquals("hello dennis zhuang", memcachedClient.get("name"));
    memcachedClient.replaceWithNoReply("name", 0, "test",
        new StringTranscoder());
    assertEquals("test", memcachedClient.get("name"));

    memcachedClient.setWithNoReply("a", 0, 1);
    GetsResponse<Integer> getsResponse = memcachedClient.gets("a");
    memcachedClient.casWithNoReply("a", 0, getsResponse,
View Full Code Here

    GetsResponse<String> getsResponse = memcachedClient.gets("name");
    GetsResponse<String> oldGetsResponse = getsResponse;
    assertEquals("dennis", getsResponse.getValue());
    long oldCas = getsResponse.getCas();
    getsResponse = memcachedClient.gets("name", 2000,
        new StringTranscoder());
    assertEquals("dennis", getsResponse.getValue());
    // check the same
    assertEquals(oldCas, getsResponse.getCas());
    assertEquals(oldGetsResponse, getsResponse);
View Full Code Here

    assertTrue(memcachedClient.set(key, 0, 2));
    assertEquals((Integer) 2, memcachedClient.get(key, 2000,
        new IntegerTranscoder()));

    assertTrue(memcachedClient.set(key, 0, "xmemcached",
        new StringTranscoder()));
    assertTrue(memcachedClient.append(key, " great"));
    assertTrue(memcachedClient.prepend(key, "hello "));

    assertEquals("hello xmemcached great", memcachedClient.get(key));
View Full Code Here

  @Test
  public void testTouch() throws Exception {
    if (isMemcached1_6()) {
      assertNull(memcachedClient.get("name"));
      memcachedClient.set("name", 1, "dennis", new StringTranscoder(),
          1000);
      assertEquals("dennis", memcachedClient.get("name",
          new StringTranscoder()));

      // touch expiration to three seconds
      System.out.println(memcachedClient.touch("name", 3));
      Thread.sleep(2000);
      assertEquals("dennis", memcachedClient.get("name",
          new StringTranscoder()));
      Thread.sleep(1500);
      assertNull(memcachedClient.get("name"));
    }
  }
View Full Code Here

  @Test
  public void testGetAndTouch_OneKey() throws Exception {
    if (isMemcached1_6()) {
      assertNull(memcachedClient.get("name"));
      memcachedClient.set("name", 1, "dennis", new StringTranscoder(),
          1000);
      assertEquals("dennis", memcachedClient.getAndTouch("name", 3));

      Thread.sleep(2000);
      assertEquals("dennis", memcachedClient.get("name",
          new StringTranscoder()));
      Thread.sleep(1500);
      assertNull(memcachedClient.get("name"));
    }
  }
View Full Code Here

  public void testCreateStoreCommand() {
    String key = "test";
    String value = "test";
    byte[] keyBytes = ByteUtils.getBytes(key);
    int exp = 0;
    Transcoder transcoder = new StringTranscoder();
    Command storeCmd = this.commandFactory.createSetCommand(key, keyBytes, exp, value,false, transcoder);
    storeCmd.encode();
    assertFalse(storeCmd.isNoreply());
    assertEquals(CommandType.SET, storeCmd.getCommandType());
    String commandStr = new String(storeCmd.getIoBuffer().buf()
View Full Code Here

  public void testCreateStoreCommand() {
    String key = "test";
    String value = "test";
    byte[] keyBytes = ByteUtils.getBytes(key);
    int exp = 0;
    Transcoder transcoder = new StringTranscoder();
    Command storeCmd = this.commandFactory.createSetCommand(key, keyBytes, exp, value,false, transcoder);
    storeCmd.encode();
    assertFalse(storeCmd.isNoreply());
    assertEquals(CommandType.SET, storeCmd.getCommandType());
    String commandStr = new String(storeCmd.getIoBuffer().buf()
View Full Code Here

TOP

Related Classes of net.rubyeye.xmemcached.transcoders.StringTranscoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.