1,快取基類
public abstract class basecache
protected void remove(string key)
protected hashmapgetmap(string key)
protected boolean containskey(string key)
protected static void registcache(basecache cache)
protected abstract mapreaddata();
public abstract hashmapgetobject();
public abstract t getvalue(string key);
public abstract void refresh();
public abstract void refreshvalue(string key, t value);
public static void loadalldata() }
}
2,乙個子類例項
public class systemargscache extends basecache
private systemargscache()
public static systemargscache getinstance()
}} return propertiescache; }
private synchronized void addchannelcache()
@override
protected mapreaddata()
@override
public hashmapgetobject()
return getmap(cache_key);
} @override
public string getvalue(string key)
@override
public void refresh()
@override
public void refreshvalue(string key, string value)
}
參考資料:
快取 SpringCache 自定義快取配置
redis 預設使用 jdk 序列化,需要我們配置序列化機制,自定義乙個配置類,否則存入的資料顯示亂碼 enablecaching 開啟快取 configuration public class mycacheconfig 使用以上配置後,雖然亂碼的問題解決了,但配置檔案又不生效了,比如過期時間等,...
java自定義異常
class chushulingexception extends exception class chushufuexception extends exception 自定義異常 end class numbertest if y 0 int m x y return m class rt001...
Java 自定義異常
自定義第乙個異常 class chushulingexception extends exception 自定義第二個異常 class chushufuexception extends exception 測試物件 class numbertest if y 0 int m x y return ...