Commit a43e53d7 authored by Liang Ding's avatar Liang Ding

#12319

parent bafb8e05
...@@ -15,8 +15,11 @@ ...@@ -15,8 +15,11 @@
*/ */
package org.b3log.solo.cache; 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.Named;
import org.b3log.latke.ioc.inject.Singleton; import org.b3log.latke.ioc.inject.Singleton;
import org.b3log.solo.model.Option;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
...@@ -33,7 +36,7 @@ public class PreferenceCache { ...@@ -33,7 +36,7 @@ public class PreferenceCache {
/** /**
* Preference cache. * Preference cache.
*/ */
private JSONObject preference; private Cache cache = CacheFactory.getCache(Option.CATEGORY_C_PREFERENCE);
/** /**
* Get the preference. * Get the preference.
...@@ -41,7 +44,7 @@ public class PreferenceCache { ...@@ -41,7 +44,7 @@ public class PreferenceCache {
* @return preference * @return preference
*/ */
public JSONObject getPreference() { public JSONObject getPreference() {
return preference; return cache.get(Option.CATEGORY_C_PREFERENCE);
} }
/** /**
...@@ -50,13 +53,13 @@ public class PreferenceCache { ...@@ -50,13 +53,13 @@ public class PreferenceCache {
* @param preference the specified preference * @param preference the specified preference
*/ */
public void putPreference(final JSONObject preference) { public void putPreference(final JSONObject preference) {
this.preference = preference; cache.put(Option.CATEGORY_C_PREFERENCE, preference);
} }
/** /**
* Clears the preference. * Clears the preference.
*/ */
public void clear() { public void clear() {
preference = null; cache.removeAll();
} }
} }
...@@ -16,15 +16,14 @@ ...@@ -16,15 +16,14 @@
package org.b3log.solo.cache; package org.b3log.solo.cache;
import org.b3log.latke.Keys; 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.Named;
import org.b3log.latke.ioc.inject.Singleton; import org.b3log.latke.ioc.inject.Singleton;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.solo.util.JSONs; import org.b3log.solo.util.JSONs;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* User cache. * User cache.
* *
...@@ -39,12 +38,12 @@ public class UserCache { ...@@ -39,12 +38,12 @@ public class UserCache {
/** /**
* Id, User. * 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. * 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. * 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