Search in sources :

Example 1 with MemCachedCache

use of com.bluenimble.platform.cache.impls.memcached.MemCachedCache in project serverless by bluenimble.

the class MemCachedPlugin method init.

@Override
public void init(final ApiServer server) throws Exception {
    Feature aFeature = Cache.class.getAnnotation(Feature.class);
    if (aFeature == null || Lang.isNullOrEmpty(aFeature.name())) {
        return;
    }
    feature = aFeature.name();
    server.addFeature(new ServerFeature() {

        private static final long serialVersionUID = 3585173809402444745L;

        @Override
        public Class<?> type() {
            return Cache.class;
        }

        @Override
        public Object get(ApiSpace space, String name) {
            return new MemCachedCache(((RecyclableCacheClient) (space.getRecyclable(createKey(name)))).client());
        }

        @Override
        public String provider() {
            return MemCachedPlugin.this.getName();
        }

        @Override
        public Plugin implementor() {
            return MemCachedPlugin.this;
        }
    });
}
Also used : ServerFeature(com.bluenimble.platform.server.ServerFeature) ApiSpace(com.bluenimble.platform.api.ApiSpace) MemCachedCache(com.bluenimble.platform.cache.impls.memcached.MemCachedCache) JsonObject(com.bluenimble.platform.json.JsonObject) Feature(com.bluenimble.platform.Feature) ServerFeature(com.bluenimble.platform.server.ServerFeature) Plugin(com.bluenimble.platform.plugins.Plugin) AbstractPlugin(com.bluenimble.platform.plugins.impls.AbstractPlugin)

Aggregations

Feature (com.bluenimble.platform.Feature)1 ApiSpace (com.bluenimble.platform.api.ApiSpace)1 MemCachedCache (com.bluenimble.platform.cache.impls.memcached.MemCachedCache)1 JsonObject (com.bluenimble.platform.json.JsonObject)1 Plugin (com.bluenimble.platform.plugins.Plugin)1 AbstractPlugin (com.bluenimble.platform.plugins.impls.AbstractPlugin)1 ServerFeature (com.bluenimble.platform.server.ServerFeature)1