-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cache for listing users, choreTypes, chores and weeklyChores (
#11)
- Loading branch information
Showing
30 changed files
with
485 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/java/services/CacheableModule.java → src/main/java/base/CacheableModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package constants; | ||
|
||
public class CacheConstants { | ||
public static final int LATEX_CACHE_EXPIRE_SECONDS = 2 * 7 * 24 * 3600; | ||
public static final int USERS_CACHE_EXPIRE_SECONDS = 4 * 7 * 24 * 3600; | ||
public static final int CHORE_TYPES_CACHE_EXPIRE_SECONDS = 4 * 7 * 24 * 3600; | ||
public static final int CHORES_CACHE_EXPIRE_SECONDS = 7 * 24 * 3600; | ||
public static final int WEEKLY_CHORES_CACHE_EXPIRE_SECONDS = 7 * 24 * 3600; | ||
|
||
public static final String USERS_REDIS_KEY_PREFIX = "api::users"; | ||
public static final String CHORES_REDIS_KEY_PREFIX = "api::chores"; | ||
public static final String WEEKLY_CHORES_REDIS_KEY_PREFIX = "api::weeklyChores"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,12 @@ | ||
package repositories; | ||
|
||
import models.Chore; | ||
import models.ChoreType; | ||
import models.Ticket; | ||
import models.User; | ||
import models.WeeklyChores; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface ChoreManagementRepository { | ||
CompletableFuture<List<Ticket>> getTickets(String userId); | ||
|
||
CompletableFuture<List<WeeklyChores>> getWeeklyChores(String userId); | ||
|
||
CompletableFuture<Void> completeTask(String userId, String weekId, String choreType); | ||
|
||
CompletableFuture<List<Chore>> getChores(String userId); | ||
|
||
CompletableFuture<Void> skipWeek(String userId, String weekId); | ||
|
||
CompletableFuture<Void> unskipWeek(String userId, String weekId); | ||
|
||
CompletableFuture<WeeklyChores> createWeeklyChores(String weekId); | ||
|
||
CompletableFuture<List<User>> listUsersAdminToken(); | ||
|
||
CompletableFuture<List<ChoreType>> getChoreTypes(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package repositories.chores; | ||
|
||
import models.Chore; | ||
import models.WeeklyChores; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface ChoresRepository { | ||
CompletableFuture<List<Chore>> listChores(String userId); | ||
CompletableFuture<List<WeeklyChores>> listWeeklyChores(String userId); | ||
CompletableFuture<WeeklyChores> createWeeklyChores(String weekId); | ||
CompletableFuture<Void> completeChore(String userId, String weekId, String choreType); | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/repositories/chores/ChoresRepositoryCacheableModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package repositories.chores; | ||
|
||
import base.CacheableModule; | ||
|
||
public class ChoresRepositoryCacheableModule extends CacheableModule { | ||
@Override | ||
protected void configure() { | ||
bind(ChoresRepository.class).to(getComponentByConfig( | ||
"chores", | ||
ChoresRepositoryCached.class, | ||
ChoresRepositoryNonCached.class)); | ||
} | ||
} |
Oops, something went wrong.