All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rt.web.util.cache.GAEMemcache Maven / Gradle / Ivy

The newest version!
package com.rt.web.util.cache;

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

import java.io.Serializable;

/**
 * 缓存
 */
public class GAEMemcache implements CacheFace {

    // google 同步缓存.
    private static MemcacheService syncCache = MemcacheServiceFactory
            .getMemcacheService();

    @Override
    public  T get(String key) {
        return (T) syncCache.get(key);
    }

    @Override
    public boolean has(String key) {
        return get(key) == null;
    }

    @Override
    public void put(String key, Serializable value) {
        syncCache.put(key, value);
    }

    @Override
    public void put(String key, Serializable value, long millis) {
        syncCache.put(key, value, Expiration.byDeltaMillis((int) millis));
    }

    @Override
    public void del(String key) {
        syncCache.delete(key);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy