Package com.google.appengine.api.memcache

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


    {
        private final static ThreadLocal<MemcacheService> PTL = new ThreadLocal<MemcacheService>();


        protected static void Enter(String ns){
            MemcacheService ds = PTL.get();
            if (null == ds){
                ds = MemcacheServiceFactory.getMemcacheService();
                PTL.set(ds);
            }
            /*
 
View Full Code Here


            return PTL.get();
        }
        protected static Entity Get(Key key){
            try {
                final String ck = BigTable.ToString(key);
                final MemcacheService mc = Store.C.Get();
                try {
                    return (Entity)mc.get(ck);
                }
                catch (ClassCastException exc){
                    /*
                     * Code change conversion
                     */
                    mc.delete(key);
                    return null;
                }
                catch (com.google.appengine.api.memcache.InvalidValueException serialization){
                    mc.delete(key);
                    return null;
                }
            }
            catch (IllegalArgumentException incompleteKey){

View Full Code Here

    DataStoreCallProcessor.clear();
    MemCacheProcessor.clear();
  }

  private static void initStorage() {
    MemcacheService memcacheService = MemcacheServiceFactory
        .getMemcacheService();
    String version = getVersion();
    byte[] object = (byte[]) memcacheService
        .get(COM_ONPOSITIVE_TRAPS_CALL_STORAGE + version);
    if (object != null) {
      DataInputStream dataInputStream = new DataInputStream(
          new ByteArrayInputStream(object));
      try {
View Full Code Here

     *
     */
    @Test
    public void memcachePut() throws Exception {
        tester.setUp();
        MemcacheService ms = MemcacheServiceFactory.getMemcacheService();
        ms.put("aaa", 1);
        tester.tearDown();
        ApiProxy.setDelegate(AppEngineTester.apiProxyLocalImpl);
        ApiProxy.setEnvironmentForCurrentThread(new TestEnvironment());
        assertThat(ms.contains("aaa"), is(false));
    }
View Full Code Here

     *
     */
    @Test
    public void memcacheIncrement() throws Exception {
        tester.setUp();
        MemcacheService ms = MemcacheServiceFactory.getMemcacheService();
        ms.increment("aaa", 1, 1L);
        tester.tearDown();
        ApiProxy.setDelegate(AppEngineTester.apiProxyLocalImpl);
        ApiProxy.setEnvironmentForCurrentThread(new TestEnvironment());
        assertThat(ms.contains("aaa"), is(false));
    }
View Full Code Here

     *
     */
    @Test
    public void memcacheIncrementAll() throws Exception {
        tester.setUp();
        MemcacheService ms = MemcacheServiceFactory.getMemcacheService();
        Map<Object, Long> offsets = new HashMap<Object, Long>();
        offsets.put("aaa", 1L);
        ms.incrementAll(offsets, 1L);
        tester.tearDown();
        ApiProxy.setDelegate(AppEngineTester.apiProxyLocalImpl);
        ApiProxy.setEnvironmentForCurrentThread(new TestEnvironment());
        assertThat(ms.contains("aaa"), is(false));
    }
View Full Code Here

import com.google.appengine.api.memcache.MemcacheServiceFactory;

public class CacheSupport {

  private static MemcacheService cacheInit(String nameSpace) {
    MemcacheService memcache = MemcacheServiceFactory.getMemcacheService(nameSpace);

    return memcache;
  }
View Full Code Here

    return memcache;
  }

  public static Object cacheGet(String nameSpace, Object id) {
    Object r = null;
    MemcacheService memcache = cacheInit(nameSpace);
    try {
      r = memcache.get(id);
    } catch (MemcacheServiceException e) {
      // nothing can be done.
    }
    return r;
  }
View Full Code Here

    }
    return r;
  }

  public static void cacheDelete(String nameSpace, Object id) {
    MemcacheService memcache = cacheInit(nameSpace);
    try {
      memcache.delete(id);
    } catch (MemcacheServiceException e) {
      // nothing can be done.
    }
  }
View Full Code Here

      // nothing can be done.
    }
  }

  public static void cachePutExp(String nameSpace, Object id, Serializable o, int exp) {
    MemcacheService memcache = cacheInit(nameSpace);
    try {
      if (exp > 0) {
        memcache.put(id, o, Expiration.byDeltaSeconds(exp));
      } else {
        memcache.put(id, o);
      }
    } catch (MemcacheServiceException e) {
      // nothing can be done.
    }
  }
View Full Code Here

TOP

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

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.