aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/UserService.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-04-07 11:13:58 +0300
committerGravatar Vitaly Takmazov2022-12-08 08:09:37 +0300
commit912171165155ff78ad111c9c4043844c34567a42 (patch)
tree876278eb4338d73d294ef55f10471d08f2b3e38b /src/main/java/com/juick/service/UserService.java
parenta6dff3324a55540877deaed23083ea502706a5ae (diff)
Configure caches
* caching is disabled because of OOMs in production
Diffstat (limited to 'src/main/java/com/juick/service/UserService.java')
-rw-r--r--src/main/java/com/juick/service/UserService.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/java/com/juick/service/UserService.java b/src/main/java/com/juick/service/UserService.java
index 06637aee..a3ab8315 100644
--- a/src/main/java/com/juick/service/UserService.java
+++ b/src/main/java/com/juick/service/UserService.java
@@ -25,6 +25,8 @@ import com.juick.model.ExternalToken;
import com.juick.util.UsernameTakenException;
import org.apache.commons.lang3.tuple.Pair;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
import javax.annotation.Nonnull;
import java.util.Collection;
@@ -44,10 +46,12 @@ public interface UserService {
String getSignUpHashByTelegramID(Long telegramId, String username);
+ @CacheEvict(value = "users_by_name", allEntries = true)
Optional<User> createUser(String username, String password) throws UsernameTakenException;
Optional<User> getUserByUID(int uid);
+ @Cacheable(value = "users_by_name")
@Nonnull User getUserByName(String username);
@Nonnull User getUserByEmail(String email);
@@ -69,6 +73,7 @@ public interface UserService {
Optional<User> checkPassword(String username, String password);
+ @CacheEvict(value = "users_by_name", allEntries = true)
boolean updatePassword(User user, String newPassword);
int getUserOptionInt(int uid, String option, int defaultValue);
@@ -174,16 +179,20 @@ public interface UserService {
String getTelegramNameByHash(String hash);
+ @CacheEvict(value = "users_by_name", allEntries = true)
boolean setFacebookUser(String hash, int uid);
String getVKNameByHash(String hash);
+ @CacheEvict(value = "users_by_name", allEntries = true)
boolean setVKUser(String hash, int uid);
+ @CacheEvict(value = "users_by_name", allEntries = true)
boolean setTelegramUser(String hash, int uid);
String getJIDByHash(String hash);
+ @CacheEvict(value = "users_by_name", allEntries = true)
boolean setJIDUser(String hash, int uid);
boolean canDeleteTelegramUser(User user);