본문 바로가기

게임서버-스파르타코딩NodeJs_7기/CH6 최종 프로젝트21

트렌젝션 적용하는 방법 트렌젝션 적용하는 방법   1. 트랜잭션 적용 요청- 질문: `AchievementPService.post` 메서드에 트랜잭션을 적용해달라는 요청.- 답변: TypeORM의 `QueryRunner`를 사용해 트랜잭션을 구현. `startTransaction`, `commitTransaction`, `rollbackTransaction`을 추가하고, 모든 DB 작업을 트랜잭션 내에서 처리하도록 수정.- 추가 조언: `AchievementPRepository`에 `getQueryRunner()` 메서드가 필요하며, 이를 위해 `DataSource` 주입이 필요함을 언급.  2. `getQueryRunner()` 메서드 추가- 질문: `AchievementPRepository`에 `getQueryRunner(.. 2025. 3. 5.
오늘 물은 내용 -Geoadd데이터 저장할 때 Geoadd데이터 저장할 때 동일한 키에 저장하기// 서브업적 서비스async fillGeo() { // 1. DB에서 모든 서브업적 가져오기 const dbSub: SubAchievement[] = await this.repository.getAll(); if (!dbSub || dbSub.length === 0) { throw new NotFoundException('DB에 서브업적 데이터가 없습니다.'); } for (const sub of dbSub) { const key = `sub-achievement`; const image = typeof sub.sub_achievement_images === 'string' .. 2025. 3. 4.
도커 핑퐁 # redis-cli 127.0.0.1:6379> pingPONG127.0.0.1:6379> 2025. 3. 4.
GEO 발키 사용 import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';import Redis from 'ioredis';@Injectable()export class GeoService implements OnModuleInit, OnModuleDestroy { private readonly S_GEO_KEY = 'sub-achievement'; // Valkey 내 Geo 데이터 키 private readonly P_GEO_KEY = 'pinkmong-appear-location'; // Valkey 내 Geo 데이터 키 private readonly client: Redis; constructor() { this.client.. 2025. 3. 4.
기존 좌표 데이터 geo발키로 수정 서브업적.서비스 async fillGeo() { // 1. DB에서 모든 서브업적 가져오기 const dbSub: SubAchievement[] = await this.repository.getAll(); if (!dbSub || dbSub.length === 0) { throw new NotFoundException('DB에 서브업적 데이터가 없습니다.'); } // 2. GeoService를 활용하여 파이프라인 생성 //const pipeline = this.geoService.multi(); for (const sub of dbSub) { const key = `sub-achievement:${sub.id}`; const image .. 2025. 3. 3.
Geo 로 거리 비교 북마커가 Valkey(기존 Redis) 데이터베이스에 저장되어 있다면,다음과 같은 방식으로 사용자 위치와 비교하여 반경 5m 이내의 북마커를 찾을 수 있습니다.📌 구현 개요Valkey에 북마커 좌표 저장 → GEOADD를 사용하여 좌표를 등록반경 5m 이내 북마커 조회 → GEORADIUSBYMEMBER 또는 GEORADIUS 사용📌 Valkey에 북마커 등록 (GEOADD 사용)import { Injectable } from '@nestjs/common';import { createClient } from 'redis';@Injectable()export class LocationService { private client; private readonly KEY = 'bookmarks'; // .. 2025. 3. 3.