| 1234567891011121314151617181920212223242526 |
- 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
- );
- }
- }
|