Commit a43e53d7 authored by Liang Ding's avatar Liang Ding

#12319

parent bafb8e05
......@@ -15,8 +15,11 @@
*/
package org.b3log.solo.cache;
import org.b3log.latke.cache.Cache;
import org.b3log.latke.cache.CacheFactory;
import org.b3log.latke.ioc.inject.Named;
import org.b3log.latke.ioc.inject.Singleton;
import org.b3log.solo.model.Option;
import org.json.JSONObject;
/**
......@@ -33,7 +36,7 @@ public class PreferenceCache {
/**
* Preference cache.
*/
private JSONObject preference;
private Cache cache = CacheFactory.getCache(Option.CATEGORY_C_PREFERENCE);
/**
* Get the preference.
......@@ -41,7 +44,7 @@ public class PreferenceCache {
* @return preference
*/
public JSONObject getPreference() {
return preference;
return cache.get(Option.CATEGORY_C_PREFERENCE);
}
/**
......@@ -50,13 +53,13 @@ public class PreferenceCache {
* @param preference the specified preference
*/
public void putPreference(final JSONObject preference) {
this.preference = preference;
cache.put(Option.CATEGORY_C_PREFERENCE, preference);
}
/**
* Clears the preference.
*/
public void clear() {
preference = null;
cache.removeAll();
}
}
......@@ -16,15 +16,14 @@
package org.b3log.solo.cache;
import org.b3log.latke.Keys;
import org.b3log.latke.cache.Cache;
import org.b3log.latke.cache.CacheFactory;
import org.b3log.latke.ioc.inject.Named;
import org.b3log.latke.ioc.inject.Singleton;
import org.b3log.latke.model.User;
import org.b3log.solo.util.JSONs;
import org.json.JSONObject;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* User cache.
*
......@@ -39,12 +38,12 @@ public class UserCache {
/**
* Id, User.
*/
private static final Map<String, JSONObject> ID_CACHE = new ConcurrentHashMap<>();
private static final Cache ID_CACHE = CacheFactory.getCache(User.USERS + "ID");
/**
* Email, User.
*/
private static final Map<String, JSONObject> EMAIL_CACHE = new ConcurrentHashMap<>();
private static final Cache EMAIL_CACHE = CacheFactory.getCache(User.USERS + "Email");
/**
* Gets a user by the specified user id.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment