package com.primeton.damp.cache; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; /** *
 *
 * Created by zhenqin.
 * User: zhenqin
 * Date: 2021/4/2
 * Time: 11:15
 * Vendor: yiidata.com
 * To change this template use File | Settings | File Templates.
 *
 * 
* * @author zhenqin */ public class GuavaMemCached implements ICache { /** * 缓存实现 */ final Cache cached = CacheBuilder.newBuilder().maximumSize(10000).initialCapacity(500).build(); public GuavaMemCached() { } @Override public void add(String key, Object value) { cached.put(key, value); } @Override public void add(String key, int exp, Object value) { cached.put(key, value); } @Override public Object get(String key) { return cached.getIfPresent(key); } @Override public Object remove(String key) { cached.invalidate(key); return null; } @Override public int removeByPrefix(String prefix) { return 0; } @Override public void clear() { cached.cleanUp(); } @Override public int size() { return (int)cached.size(); } @Override public void shutdown() { clear(); } }