chore: redis cache for calendars in api v2 (#23622)
* chore: implement redis cache for calendars api v2 * fixup! chore: implement redis cache for calendars api v2 * fixup! fixup! chore: implement redis cache for calendars api v2 * fix leverage genetic type of redis.get * refactor: address supalarry's PR feedback - Create CalendarsCacheService to separate cache responsibilities - Rename cache methods to be more descriptive (getConnectedAndDestinationCalendarsCache, setConnectedAndDestinationCalendarsCache) - Remove unused redisService injection from CalendarsController - Move all cache-related functionality to dedicated service Addresses comments 9, 10, and 11 from supalarry on PR #23622 Co-Authored-By: [email protected] <[email protected]> * refactor: address supalarry's latest PR feedback - Remove redundant deleteConnectedAndDestinationCalendarsCache from CalendarsService - Update controller to directly inject and use CalendarsCacheService - Extract TTL constant and remove manual JSON.stringify in cache service Co-Authored-By: [email protected] <[email protected]> * fix: update IcsFeedService to use CalendarsCacheService directly - Inject CalendarsCacheService into IcsFeedService constructor - Replace calendarsService.deleteCalendarCache with calendarsCacheService.deleteConnectedAndDestinationCalendarsCache - Completes the refactoring to eliminate all old cache method references Co-Authored-By: [email protected] <[email protected]> * fix: update destination-calendars and selected-calendars services to use CalendarsCacheService directly - Inject CalendarsCacheService in both service constructors - Replace calendarsService.deleteCalendarCache calls with calendarsCacheService.deleteConnectedAndDestinationCalendarsCache - Add CalendarsCacheService to module providers for proper dependency injection - Completes migration of all cache method references to use dedicated cache service Co-Authored-By: [email protected] <[email protected]> * chore: use CalendarsCacheService --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
17 files changed
+205
-21
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { CalendarsRepository } from "@/ee/calendars/calendars.repository";
|
||||
import { CalendarsCacheService } from "@/ee/calendars/services/calendars-cache.service";
|
||||
import { CalendarsService } from "@/ee/calendars/services/calendars.service";
|
||||
import { AppsRepository } from "@/modules/apps/apps.repository";
|
||||
import { CredentialsRepository } from "@/modules/credentials/credentials.repository";
|
||||
@@ -7,6 +8,7 @@ import { OrganizationsMembershipRepository } from "@/modules/organizations/membe
|
||||
import { OrganizationsMembershipOutputService } from "@/modules/organizations/memberships/services/organizations-membership-output.service";
|
||||
import { OrganizationsMembershipService } from "@/modules/organizations/memberships/services/organizations-membership.service";
|
||||
import { PrismaModule } from "@/modules/prisma/prisma.module";
|
||||
import { RedisModule } from "@/modules/redis/redis.module";
|
||||
import { SelectedCalendarsController } from "@/modules/selected-calendars/controllers/selected-calendars.controller";
|
||||
import { SelectedCalendarsRepository } from "@/modules/selected-calendars/selected-calendars.repository";
|
||||
import { SelectedCalendarsService } from "@/modules/selected-calendars/services/selected-calendars.service";
|
||||
@@ -14,11 +16,12 @@ import { UsersRepository } from "@/modules/users/users.repository";
|
||||
import { Module } from "@nestjs/common";
|
||||
|
||||
@Module({
|
||||
imports: [PrismaModule],
|
||||
imports: [PrismaModule, RedisModule],
|
||||
providers: [
|
||||
SelectedCalendarsRepository,
|
||||
CalendarsRepository,
|
||||
CalendarsService,
|
||||
CalendarsCacheService,
|
||||
UsersRepository,
|
||||
CredentialsRepository,
|
||||
AppsRepository,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { CalendarsCacheService } from "@/ee/calendars/services/calendars-cache.service";
|
||||
import { CalendarsService } from "@/ee/calendars/services/calendars.service";
|
||||
import { OrganizationsDelegationCredentialRepository } from "@/modules/organizations/delegation-credentials/organizations-delegation-credential.repository";
|
||||
import { OrganizationsMembershipService } from "@/modules/organizations/memberships/services/organizations-membership.service";
|
||||
@@ -23,6 +24,7 @@ type SelectedCalendarsInputDelegationCredential = SelectedCalendarsInputDto & {
|
||||
export class SelectedCalendarsService {
|
||||
constructor(
|
||||
private readonly calendarsService: CalendarsService,
|
||||
private readonly calendarsCacheService: CalendarsCacheService,
|
||||
private readonly selectedCalendarsRepository: SelectedCalendarsRepository,
|
||||
private readonly organizationsMembershipService: OrganizationsMembershipService,
|
||||
private readonly organizationsDelegationCredentialRepository: OrganizationsDelegationCredentialRepository
|
||||
@@ -50,6 +52,8 @@ export class SelectedCalendarsService {
|
||||
credentialId
|
||||
);
|
||||
|
||||
await this.calendarsCacheService.deleteConnectedAndDestinationCalendarsCache(user.id);
|
||||
|
||||
return userSelectedCalendar;
|
||||
}
|
||||
|
||||
@@ -122,7 +126,7 @@ export class SelectedCalendarsService {
|
||||
externalId,
|
||||
delegationCredentialId
|
||||
);
|
||||
|
||||
await this.calendarsCacheService.deleteConnectedAndDestinationCalendarsCache(user.id);
|
||||
return removedCalendarEntry;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
|
||||
Reference in new issue
Block a user