| 123456789101112131415161718192021222324252627282930313233343536 |
- import { Injectable } from '@nestjs/common';
- import { BaseCacheService } from '@box/common/cache/cache-service';
- import { tsCacheKeys } from '@box/common/cache/ts-cache-key.provider';
- import { ChannelCachePayload } from './channel-cache.builder';
- import { RedisService } from '@box/db/redis/redis.service';
- @Injectable()
- export class ChannelCacheService extends BaseCacheService {
- constructor(redis: RedisService) {
- super(redis, ChannelCacheService.name);
- }
- async getAllChannels(): Promise<ChannelCachePayload[]> {
- return (
- (await this.getJson<ChannelCachePayload[]>(tsCacheKeys.channel.all())) ??
- []
- );
- }
- // async getChannelById(id: string): Promise<ChannelCachePayload | null> {
- // if (!id) return null;
- // return (
- // (await this.getJson<ChannelCachePayload>(tsCacheKeys.channel.byId(id))) ??
- // null
- // );
- // }
- async getChannelById(channelId: string): Promise<ChannelCachePayload | null> {
- if (!channelId) return null;
- return (
- (await this.getJson<ChannelCachePayload>(
- tsCacheKeys.channel.byId(channelId),
- )) ?? null
- );
- }
- }
|