Package com.google.appengine.api.memcache.MemcacheService

Examples of com.google.appengine.api.memcache.MemcacheService.CasValues


      MemcacheSetRequest.Item.Builder itemBuilder = MemcacheSetRequest.Item.newBuilder();
      requestedKeys.add(entry.getKey());
      itemBuilder.setKey(makePbKey(entry.getKey()));
      ValueAndFlags vaf;
      if (policy == MemcacheSetRequest.SetPolicy.CAS) {
        CasValues value = (CasValues) entry.getValue();
        if (value == null) {
          throw new IllegalArgumentException(entry.getKey() + " has a null for CasValues");
        }
        vaf = serializeValue(value.getNewValue());
        if (!(value.getOldValue() instanceof IdentifiableValueImpl)) {
          throw new IllegalArgumentException(
            entry.getKey() + " CasValues has an oldValue instance of an unapproved " +
            "IdentifiableValue implementation.  Perhaps you implemented your own " +
            "version of IdentifiableValue?  If so, don't do this.");
        }
        itemBuilder.setCasId(((IdentifiableValueImpl) value.getOldValue()).getCasId());
        if (value.getExipration() != null) {
          itemBuilder.setExpirationTime(value.getExipration().getSecondsValue());
        } else {
          itemBuilder.setExpirationTime(expires == null ? 0 : expires.getSecondsValue());
        }
      } else {
        vaf = serializeValue(entry.getValue());
View Full Code Here


      MemcacheSetRequest.Item.Builder itemBuilder = MemcacheSetRequest.Item.newBuilder();
      requestedKeys.add(entry.getKey());
      itemBuilder.setKey(makePbKey(entry.getKey()));
      ValueAndFlags vaf;
      if (policy == MemcacheSetRequest.SetPolicy.CAS) {
        CasValues value = (CasValues) entry.getValue();
        if (value == null) {
          throw new IllegalArgumentException(entry.getKey() + " has a null for CasValues");
        }
        vaf = serializeValue(value.getNewValue());
        if (!(value.getOldValue() instanceof IdentifiableValueImpl)) {
          throw new IllegalArgumentException(
            entry.getKey() + " CasValues has an oldValue instance of an unapproved " +
            "IdentifiableValue implementation.  Perhaps you implemented your own " +
            "version of IdentifiableValue?  If so, don't do this.");
        }
        itemBuilder.setCasId(((IdentifiableValueImpl) value.getOldValue()).getCasId());
        if (value.getExipration() != null) {
          itemBuilder.setExpirationTime(value.getExipration().getSecondsValue());
        } else {
          itemBuilder.setExpirationTime(expires == null ? 0 : expires.getSecondsValue());
        }
      } else {
        vaf = serializeValue(entry.getValue());
View Full Code Here

      if (expirySeconds == null)
        continue;

      Expiration expiration = expirySeconds == 0 ? null : Expiration.byDeltaSeconds(expirySeconds);

      payload.put(buck.getKey(), new CasValues(buck.iv, buck.getNextToStore(), expiration));
    }

    return this.memcache.putIfUntouched(payload);
  }
View Full Code Here

        memcache.putAll(inputDat);
        Set<Object> set;

        Map<Object, CasValues> updateDat = new HashMap<Object, CasValues>();
        for (Object key : testDat) {
            updateDat.put(key, new CasValues(memcache.getIdentifiable(key), "new value"));
        }
        Future<Set<Object>> futureSet = asyncMemcache.putIfUntouched(updateDat);
        set = waitOnFuture(futureSet);
        assertEquals(2, set.size());
        assertEquals("new value", memcache.get(testDat[0]));
View Full Code Here

        memcache.putAll(inputDat);
        Set<Object> set;

        Map<Object, CasValues> updateDat = new HashMap<Object, CasValues>();
        for (Object key : testDat) {
            updateDat.put(key, new CasValues(memcache.getIdentifiable(key), "new value", Expiration.byDeltaSeconds(60 * 60)));
        }
        Future<Set<Object>> futureSet = asyncMemcache.putIfUntouched(updateDat, Expiration.byDeltaMillis(1000));
        set = waitOnFuture(futureSet);
        assertEquals(2, set.size());
        assertEquals("new value", memcache.get(testDat[0]));
View Full Code Here

TOP

Related Classes of com.google.appengine.api.memcache.MemcacheService.CasValues

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.