Commit fcd76d3c authored by Liang Ding's avatar Liang Ding

🎨 #12319 命名重构

parent 6bcd7fe9
...@@ -38,11 +38,7 @@ public class ArticleCache { ...@@ -38,11 +38,7 @@ public class ArticleCache {
/** /**
* Article cache. * Article cache.
*/ */
private static final Cache ARTICLE_CACHE = CacheFactory.getCache(Article.ARTICLES); private Cache cache = CacheFactory.getCache(Article.ARTICLES);
static {
ARTICLE_CACHE.setMaxCount(128);
}
/** /**
* Gets an article by the specified article id. * Gets an article by the specified article id.
...@@ -51,7 +47,7 @@ public class ArticleCache { ...@@ -51,7 +47,7 @@ public class ArticleCache {
* @return article, returns {@code null} if not found * @return article, returns {@code null} if not found
*/ */
public JSONObject getArticle(final String id) { public JSONObject getArticle(final String id) {
final JSONObject article = ARTICLE_CACHE.get(id); final JSONObject article = cache.get(id);
if (null == article) { if (null == article) {
return null; return null;
} }
...@@ -67,7 +63,7 @@ public class ArticleCache { ...@@ -67,7 +63,7 @@ public class ArticleCache {
public void putArticle(final JSONObject article) { public void putArticle(final JSONObject article) {
final String articleId = article.optString(Keys.OBJECT_ID); final String articleId = article.optString(Keys.OBJECT_ID);
ARTICLE_CACHE.put(articleId, JSONs.clone(article)); cache.put(articleId, JSONs.clone(article));
} }
/** /**
...@@ -76,6 +72,6 @@ public class ArticleCache { ...@@ -76,6 +72,6 @@ public class ArticleCache {
* @param id the specified article id * @param id the specified article id
*/ */
public void removeArticle(final String id) { public void removeArticle(final String id) {
ARTICLE_CACHE.remove(id); cache.remove(id);
} }
} }
\ No newline at end of file
...@@ -38,11 +38,7 @@ public class CommentCache { ...@@ -38,11 +38,7 @@ public class CommentCache {
/** /**
* Comment cache. * Comment cache.
*/ */
private static final Cache cache = CacheFactory.getCache(Comment.COMMENTS); private Cache cache = CacheFactory.getCache(Comment.COMMENTS);
static {
cache.setMaxCount(512);
}
/** /**
* Gets a comment by the specified comment id. * Gets a comment by the specified comment id.
......
...@@ -38,11 +38,7 @@ public class OptionCache { ...@@ -38,11 +38,7 @@ public class OptionCache {
/** /**
* Option cache. * Option cache.
*/ */
private static final Cache CACHE = CacheFactory.getCache(Option.OPTIONS); private Cache CACHE = CacheFactory.getCache(Option.OPTIONS);
static {
CACHE.setMaxCount(512);
}
/** /**
* Gets an option by the specified option id. * Gets an option by the specified option id.
......
...@@ -38,11 +38,7 @@ public class PageCache { ...@@ -38,11 +38,7 @@ public class PageCache {
/** /**
* Page cache. * Page cache.
*/ */
private static final Cache PAGE_CACHE = CacheFactory.getCache(Page.PAGES); private Cache cache = CacheFactory.getCache(Page.PAGES);
static {
PAGE_CACHE.setMaxCount(128);
}
/** /**
* Gets a page by the specified page id. * Gets a page by the specified page id.
...@@ -51,7 +47,7 @@ public class PageCache { ...@@ -51,7 +47,7 @@ public class PageCache {
* @return page, returns {@code null} if not found * @return page, returns {@code null} if not found
*/ */
public JSONObject getPage(final String id) { public JSONObject getPage(final String id) {
final JSONObject page = PAGE_CACHE.get(id); final JSONObject page = cache.get(id);
if (null == page) { if (null == page) {
return null; return null;
} }
...@@ -67,7 +63,7 @@ public class PageCache { ...@@ -67,7 +63,7 @@ public class PageCache {
public void putPage(final JSONObject page) { public void putPage(final JSONObject page) {
final String pageId = page.optString(Keys.OBJECT_ID); final String pageId = page.optString(Keys.OBJECT_ID);
PAGE_CACHE.put(pageId, JSONs.clone(page)); cache.put(pageId, JSONs.clone(page));
} }
/** /**
...@@ -76,6 +72,6 @@ public class PageCache { ...@@ -76,6 +72,6 @@ public class PageCache {
* @param id the specified page id * @param id the specified page id
*/ */
public void removePage(final String id) { public void removePage(final String id) {
PAGE_CACHE.remove(id); cache.remove(id);
} }
} }
...@@ -39,17 +39,17 @@ public class UserCache { ...@@ -39,17 +39,17 @@ public class UserCache {
/** /**
* Id, User. * Id, User.
*/ */
private static final Cache ID_CACHE = CacheFactory.getCache(User.USERS + "ID"); private Cache idCache = CacheFactory.getCache(User.USERS + "ID");
/** /**
* Email, User. * Email, User.
*/ */
private static final Cache EMAIL_CACHE = CacheFactory.getCache(User.USERS + "Email"); private Cache emailCache = CacheFactory.getCache(User.USERS + "Email");
/** /**
* Admin user. * Admin user.
*/ */
private static final Cache ADMIN_CACHE = CacheFactory.getCache("adminUser"); private Cache adminCache = CacheFactory.getCache("adminUser");
/** /**
* Gets the admin user. * Gets the admin user.
...@@ -57,7 +57,7 @@ public class UserCache { ...@@ -57,7 +57,7 @@ public class UserCache {
* @return admin user * @return admin user
*/ */
public JSONObject getAdmin() { public JSONObject getAdmin() {
return ADMIN_CACHE.get(Role.ADMIN_ROLE); return adminCache.get(Role.ADMIN_ROLE);
} }
/** /**
...@@ -66,7 +66,7 @@ public class UserCache { ...@@ -66,7 +66,7 @@ public class UserCache {
* @param admin the specified admin user * @param admin the specified admin user
*/ */
public void putAdmin(final JSONObject admin) { public void putAdmin(final JSONObject admin) {
ADMIN_CACHE.put(Role.ADMIN_ROLE, admin); adminCache.put(Role.ADMIN_ROLE, admin);
} }
/** /**
...@@ -76,7 +76,7 @@ public class UserCache { ...@@ -76,7 +76,7 @@ public class UserCache {
* @return user, returns {@code null} if not found * @return user, returns {@code null} if not found
*/ */
public JSONObject getUser(final String userId) { public JSONObject getUser(final String userId) {
final JSONObject user = ID_CACHE.get(userId); final JSONObject user = idCache.get(userId);
if (null == user) { if (null == user) {
return null; return null;
} }
...@@ -91,7 +91,7 @@ public class UserCache { ...@@ -91,7 +91,7 @@ public class UserCache {
* @return user, returns {@code null} if not found * @return user, returns {@code null} if not found
*/ */
public JSONObject getUserByEmail(final String userEmail) { public JSONObject getUserByEmail(final String userEmail) {
final JSONObject user = EMAIL_CACHE.get(userEmail); final JSONObject user = emailCache.get(userEmail);
if (null == user) { if (null == user) {
return null; return null;
} }
...@@ -105,8 +105,8 @@ public class UserCache { ...@@ -105,8 +105,8 @@ public class UserCache {
* @param user the specified user * @param user the specified user
*/ */
public void putUser(final JSONObject user) { public void putUser(final JSONObject user) {
ID_CACHE.put(user.optString(Keys.OBJECT_ID), JSONs.clone(user)); idCache.put(user.optString(Keys.OBJECT_ID), JSONs.clone(user));
EMAIL_CACHE.put(user.optString(User.USER_EMAIL), JSONs.clone(user)); emailCache.put(user.optString(User.USER_EMAIL), JSONs.clone(user));
} }
/** /**
...@@ -115,14 +115,14 @@ public class UserCache { ...@@ -115,14 +115,14 @@ public class UserCache {
* @param id the specified user id * @param id the specified user id
*/ */
public void removeUser(final String id) { public void removeUser(final String id) {
final JSONObject user = ID_CACHE.get(id); final JSONObject user = idCache.get(id);
if (null == user) { if (null == user) {
return; return;
} }
ID_CACHE.remove(id); idCache.remove(id);
final String email = user.optString(User.USER_EMAIL); final String email = user.optString(User.USER_EMAIL);
EMAIL_CACHE.remove(email); emailCache.remove(email);
} }
} }
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