Package net.rubyeye.xmemcached.transcoders

Examples of net.rubyeye.xmemcached.transcoders.CachedData


    final Command command = this.commandFactory.createGetCommand(key,
        keyBytes, cmdType, this.transcoder);
    this.latchWait(command, timeout, this.sendCommand(command));
    command.getIoBuffer().free(); // free buffer
    this.checkException(command);
    CachedData data = (CachedData) command.getResult();
    if (data == null) {
      return null;
    }
    if (transcoder == null) {
      transcoder = this.transcoder;
    }
    if (cmdType == CommandType.GETS_ONE) {
      return new GetsResponse<T>(data.getCas(), transcoder.decode(data));
    } else {
      return transcoder.decode(data);
    }
  }
View Full Code Here


    final Command command = this.commandFactory.createGetAndTouchCommand(
        key, keyBytes, latch, newExp, false);
    this.latchWait(command, opTimeout, this.sendCommand(command));
    command.getIoBuffer().free();
    this.checkException(command);
    CachedData data = (CachedData) command.getResult();
    if (data == null) {
      return null;
    }
    return (T) this.transcoder.decode(data);
  }
View Full Code Here

        keyBytes, cmdType, this.transcoder);
    this.sendCommand(command);
    this.latchWait(command, timeout);
    command.getIoBuffer().free(); // free buffer
    this.checkException(command);
    CachedData data = (CachedData) command.getResult();
    if (data == null) {
      return null;
    }
    if (transcoder == null) {
      transcoder = this.transcoder;
    }
    if (cmdType == CommandType.GETS_ONE) {
      return new GetsResponse<T>(data.getCas(), transcoder.decode(data));
    } else {
      return transcoder.decode(data);
    }
  }
View Full Code Here

        key, keyBytes, latch, newExp, false);
    this.sendCommand(command);
    this.latchWait(command, opTimeout);
    command.getIoBuffer().free();
    this.checkException(command);
    CachedData data = (CachedData) command.getResult();
    if (data == null) {
      return null;
    }
    return (T) transcoder.decode(data);
  }
View Full Code Here

  static final byte EXTRAS_LENGTH = (byte) 8;

  @Override
  @SuppressWarnings("unchecked")
  public void encode() {
    CachedData data = null;
    if (this.transcoder != null) {
      data = this.transcoder.encode(this.value);
    }
    // header+key+value+extras
    int length = 24 + getKeyLength() + getValueLength(data)
View Full Code Here

  public void testCompressedStringNotSmaller() throws Exception {
    String s1="This is a test simple string that will not be compressed.";
    // Reduce the compression threshold so it'll attempt to compress it.
    tc.setCompressionThreshold(8);
    CachedData cd=tc.encode(s1);
    // This should *not* be compressed because it is too small
    assertEquals(0, cd.getFlag());
    assertTrue(Arrays.equals(s1.getBytes(), cd.getData()));
    assertEquals(s1, tc.decode(cd));
  }
View Full Code Here

  public void testCompressedString() throws Exception {
    // This one will actually compress
    String s1="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    tc.setCompressionThreshold(8);
    CachedData cd=tc.encode(s1);
    assertEquals(SerializingTranscoder.COMPRESSED, cd.getFlag());
    assertFalse(Arrays.equals(s1.getBytes(), cd.getData()));
    assertEquals(s1, tc.decode(cd));
  }
View Full Code Here

    assertEquals(s1, tc.decode(cd));
  }

  public void testObject() throws Exception {
    Calendar c=Calendar.getInstance();
    CachedData cd=tc.encode(c);
    assertEquals(SerializingTranscoder.SERIALIZED, cd.getFlag());
    assertEquals(c, tc.decode(cd));
  }
View Full Code Here

  }

  public void testCompressedObject() throws Exception {
    tc.setCompressionThreshold(8);
    Calendar c=Calendar.getInstance();
    CachedData cd=tc.encode(c);
    assertEquals(SerializingTranscoder.SERIALIZED
        |SerializingTranscoder.COMPRESSED, cd.getFlag());
    assertEquals(c, tc.decode(cd));
  }
View Full Code Here

    assertEquals(c, tc.decode(cd));
  }

  public void testUnencodeable() throws Exception {
    try {
      CachedData cd=tc.encode(new Object());
      fail("Should fail to serialize, got" + cd);
    } catch(IllegalArgumentException e) {
      // pass
    }
  }
View Full Code Here

TOP

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

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.