Package net.rubyeye.xmemcached

Examples of net.rubyeye.xmemcached.KeyIterator


  public void testKeyIterator() throws Exception {
    if (memcachedClient.getProtocol() == Protocol.Text) {
      Collection<InetSocketAddress> avaliableServers = memcachedClient
          .getAvaliableServers();
      InetSocketAddress address = avaliableServers.iterator().next();
      KeyIterator it = memcachedClient.getKeyIterator(address);
      while (it.hasNext()) {
        memcachedClient.delete(it.next());
      }
      it = memcachedClient.getKeyIterator(address);
      Assert.assertFalse(it.hasNext());
      try {
        it.next();
        Assert.fail();
      } catch (NoSuchElementException e) {
        Assert.assertTrue(true);
      }
      for (int i = 0; i < 10; i++) {
        memcachedClient.set(String.valueOf(i), 0, i);
      }
      it = memcachedClient.getKeyIterator(address);
      Assert.assertTrue(it.hasNext());
      Assert.assertEquals(address, it.getServerAddress());
      while (it.hasNext()) {
        String key = it.next();
        Assert.assertEquals(Integer.parseInt(key), memcachedClient
            .get(key));
      }
      Assert.assertFalse(it.hasNext());
    } else {
      // ignore
    }

  }
View Full Code Here


      value = memcachedClient.get("a");
      System.out.println("after delete,a=" + value);

      System.out.println("Iterate all keys...");
      // iterate all keys
      KeyIterator it = memcachedClient.getKeyIterator(AddrUtil
          .getOneAddress(args[0]));
      while (it.hasNext()) {
        System.out.println(it.next());
      }

    } catch (MemcachedException e) {
      System.err.println("MemcachedClient operation fail");
      e.printStackTrace();
View Full Code Here

      value = memcachedClient.get("a");
      System.out.println("after delete,a=" + value);

      System.out.println("Iterate all keys...");
      // iterate all keys
      KeyIterator it = memcachedClient.getKeyIterator(AddrUtil
          .getOneAddress(args[0]));
      while (it.hasNext()) {
        System.out.println(it.next());
      }
      System.out.println(memcachedClient.touch("b", 1000));

    } catch (MemcachedException e) {
      System.err.println("MemcachedClient operation fail");
View Full Code Here

TOP

Related Classes of net.rubyeye.xmemcached.KeyIterator

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.