Commit fcd76d3c authored by Liang Ding's avatar Liang Ding

🎨 #12319 命名重构

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