Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc150e5f

Browse files
committed
Fix CacheStore errors from checkstyle plugin 107 left
1 parent3c213fc commitc150e5f

File tree

1 file changed

+40
-12
lines changed

1 file changed

+40
-12
lines changed

‎caching/src/main/java/com/iluwatar/caching/CacheStore.java

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,34 @@
3535
*/
3636
@Slf4j
3737
publicclassCacheStore {
38+
/**
39+
* Cach capacity.
40+
*/
3841
privatestaticfinalintCAPACITY =3;
3942

43+
/**
44+
* Lru cache see {@link LruCache}.
45+
*/
4046
privatestaticLruCachecache;
47+
/**
48+
* DbManager.
49+
*/
4150
privateDbManagerdbManager;
4251

43-
publicCacheStore(DbManagerdbManager) {
44-
this.dbManager =dbManager;
52+
/**
53+
* Cache Store.
54+
* @param dataBaseManager {@link DbManager}
55+
*/
56+
publicCacheStore(finalDbManagerdataBaseManager) {
57+
this.dbManager =dataBaseManager;
4558
initCapacity(CAPACITY);
4659
}
4760

4861
/**
4962
* Init cache capacity.
63+
* @param capacity int
5064
*/
51-
publicvoidinitCapacity(intcapacity) {
65+
publicvoidinitCapacity(finalintcapacity) {
5266
if (cache ==null) {
5367
cache =newLruCache(capacity);
5468
}else {
@@ -58,8 +72,10 @@ public void initCapacity(int capacity) {
5872

5973
/**
6074
* Get user account using read-through cache.
75+
* @param userId {@link String}
76+
* @return {@link UserAccount}
6177
*/
62-
publicUserAccountreadThrough(StringuserId) {
78+
publicUserAccountreadThrough(finalStringuserId) {
6379
if (cache.contains(userId)) {
6480
LOGGER.info("# Found in Cache!");
6581
returncache.get(userId);
@@ -72,8 +88,9 @@ public UserAccount readThrough(String userId) {
7288

7389
/**
7490
* Get user account using write-through cache.
91+
* @param userAccount {@link UserAccount}
7592
*/
76-
publicvoidwriteThrough(UserAccountuserAccount) {
93+
publicvoidwriteThrough(finalUserAccountuserAccount) {
7794
if (cache.contains(userAccount.getUserId())) {
7895
dbManager.updateDb(userAccount);
7996
}else {
@@ -84,11 +101,13 @@ public void writeThrough(UserAccount userAccount) {
84101

85102
/**
86103
* Get user account using write-around cache.
104+
* @param userAccount {@link UserAccount}
87105
*/
88-
publicvoidwriteAround(UserAccountuserAccount) {
106+
publicvoidwriteAround(finalUserAccountuserAccount) {
89107
if (cache.contains(userAccount.getUserId())) {
90108
dbManager.updateDb(userAccount);
91-
cache.invalidate(userAccount.getUserId());// Cache data has been updated -- remove older
109+
// Cache data has been updated -- remove older
110+
cache.invalidate(userAccount.getUserId());
92111
// version from cache.
93112
}else {
94113
dbManager.writeToDb(userAccount);
@@ -97,8 +116,10 @@ public void writeAround(UserAccount userAccount) {
97116

98117
/**
99118
* Get user account using read-through cache with write-back policy.
119+
* @param userId {@link String}
120+
* @return {@link UserAccount}
100121
*/
101-
publicUserAccountreadThroughWithWriteBackPolicy(StringuserId) {
122+
publicUserAccountreadThroughWithWriteBackPolicy(finalStringuserId) {
102123
if (cache.contains(userId)) {
103124
LOGGER.info("# Found in cache!");
104125
returncache.get(userId);
@@ -116,8 +137,9 @@ public UserAccount readThroughWithWriteBackPolicy(String userId) {
116137

117138
/**
118139
* Set user account.
140+
* @param userAccount {@link UserAccount}
119141
*/
120-
publicvoidwriteBehind(UserAccountuserAccount) {
142+
publicvoidwriteBehind(finalUserAccountuserAccount) {
121143
if (cache.isFull() && !cache.contains(userAccount.getUserId())) {
122144
LOGGER.info("# Cache is FULL! Writing LRU data to DB...");
123145
UserAccounttoBeWrittenToDb =cache.getLruData();
@@ -148,6 +170,7 @@ public void flushCache() {
148170

149171
/**
150172
* Print user accounts.
173+
* @return {@link String}
151174
*/
152175
publicStringprint() {
153176
returnOptional.ofNullable(cache)
@@ -160,22 +183,27 @@ public String print() {
160183

161184
/**
162185
* Delegate to backing cache store.
186+
* @param userId {@link String}
187+
* @return {@link UserAccount}
163188
*/
164-
publicUserAccountget(StringuserId) {
189+
publicUserAccountget(finalStringuserId) {
165190
returncache.get(userId);
166191
}
167192

168193
/**
169194
* Delegate to backing cache store.
195+
* @param userId {@link String}
196+
* @param userAccount {@link UserAccount}
170197
*/
171-
publicvoidset(StringuserId,UserAccountuserAccount) {
198+
publicvoidset(finalStringuserId,finalUserAccountuserAccount) {
172199
cache.set(userId,userAccount);
173200
}
174201

175202
/**
176203
* Delegate to backing cache store.
204+
* @param userId {@link String}
177205
*/
178-
publicvoidinvalidate(StringuserId) {
206+
publicvoidinvalidate(finalStringuserId) {
179207
cache.invalidate(userId);
180208
}
181209
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp