728x90
발키 서비스에 코드 추가
async getKeysByPattern(
pattern: string,
count: number = 100,
): Promise<string[]> {
let cursor = '0';
let keys: string[] = [];
do {
const [newCursor, foundKeys]: [string, string[]] = await this.client.scan(
cursor,
'MATCH',
pattern,
'COUNT',
count.toString(),
);
cursor = newCursor;
if (Array.isArray(foundKeys)) {
keys = keys.concat(foundKeys);
}
} while (cursor !== '0');
return keys;
}
읽어오기
import {
Injectable,
NotFoundException,
BadRequestException,
ParseIntPipe,
} from '@nestjs/common';
import { SubAchievement } from '../sub-achievement/entities/sub-achievement.entity';
import { PinkmongAppearLocation } from '../pinkmong-appear-location/entities/pinkmong-appear-location.entity';
import { CreateDirectionDto } from './dto/create-direction.dto';
import { UpdateDirectionDto } from './dto/update-direction.dto';
import { S3Service } from '../s3/s3.service';
import { ValkeyService } from '../valkey/valkey.service';
import { Entity } from 'typeorm';
@Injectable()
export class DirectionService {
constructor(
private readonly subEntity: SubAchievement,
private readonly pinkEntity: PinkmongAppearLocation,
private readonly s3Service: S3Service,
private readonly valkeyService: ValkeyService,
) {}
async createBookmarks() {
// ✅ Redis SCAN을 사용하여 패턴에 맞는 키들을 가져옴
// 서브업적 빌키에서 읽어오기
const keyS = await this.valkeyService.getKeysByPattern(`sub-achievement:*`);
console.log('🔍 keysS 확인:', keyS);
...
'내일배움 과제 > 최종 프로젝트' 카테고리의 다른 글
마커로 길찾기 (0) | 2025.02.20 |
---|---|
html에서 카카오 지도 api 사용하기 (0) | 2025.02.19 |
웹소켓, 카카오맵 api 사용 계획 (0) | 2025.02.19 |
트러블슈팅 - 업적 dto의 날짜 타입이 적절치 않아 발생한 오류 (0) | 2025.02.17 |
오늘 회의, 멘토링 (0) | 2025.02.13 |