9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
5.4 KiB
5.4 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-비동기-데이터-관리 | 비동기 데이터 관리 | 10_Wiki/Topics | verified | self |
|
none | A | 0.92 | applied |
|
2026-05-10 | pending |
|
비동기 데이터 관리
매 한 줄
"매 server state 의 client cache 의 separation". 매 fetch / cache / sync / invalidate / retry / dedupe 의 7 concerns 의 library 의 delegation — 매 2026 의 TanStack Query (v5) / SWR / RTK Query 의 standard. Custom
useEffect + fetch의 anti-pattern.
매 핵심
매 server vs client state
- client state: form input, modal open/close, theme — local, ephemeral. Zustand/useState.
- server state: 매 remote source of truth — async, stale, shared, cached. TanStack Query.
매 7 concerns
- Fetch: HTTP request + abort.
- Cache: key-based store.
- Dedupe: 매 simultaneous request 의 share.
- Stale: time-based freshness.
- Background refetch: window focus, reconnect.
- Retry: exponential backoff.
- Invalidate: mutation 후 refetch.
매 query lifecycle
fetching → fresh (staleTime) → stale → refetch → fresh
↓
gcTime → garbage collect
💻 패턴
TanStack Query v5 (React)
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
function UserProfile({ id }: { id: string }) {
const { data, isLoading, error } = useQuery({
queryKey: ['user', id],
queryFn: ({ signal }) => fetch(`/api/users/${id}`, { signal }).then(r => r.json()),
staleTime: 60_000, // 1min fresh
gcTime: 5 * 60_000, // 5min cache
});
if (isLoading) return <Skeleton />;
if (error) return <Error error={error} />;
return <Profile user={data} />;
}
Mutation + invalidation
function useUpdateUser() {
const qc = useQueryClient();
return useMutation({
mutationFn: (user: User) =>
fetch(`/api/users/${user.id}`, {
method: 'PUT', body: JSON.stringify(user),
}).then(r => r.json()),
onSuccess: (_, user) => {
qc.invalidateQueries({ queryKey: ['user', user.id] });
qc.invalidateQueries({ queryKey: ['users'] });
},
});
}
Optimistic update
useMutation({
mutationFn: toggleTodo,
onMutate: async (id) => {
await qc.cancelQueries({ queryKey: ['todos'] });
const prev = qc.getQueryData(['todos']);
qc.setQueryData(['todos'], (old: Todo[]) =>
old.map(t => t.id === id ? { ...t, done: !t.done } : t));
return { prev };
},
onError: (_, __, ctx) => qc.setQueryData(['todos'], ctx?.prev),
onSettled: () => qc.invalidateQueries({ queryKey: ['todos'] }),
});
Infinite scroll
const { data, fetchNextPage, hasNextPage } = useInfiniteQuery({
queryKey: ['posts'],
queryFn: ({ pageParam = 0 }) =>
fetch(`/api/posts?cursor=${pageParam}`).then(r => r.json()),
getNextPageParam: (last) => last.nextCursor,
initialPageParam: 0,
});
Suspense mode (React 19)
const { data } = useSuspenseQuery({
queryKey: ['user', id],
queryFn: fetchUser,
});
// data 의 always defined — Suspense boundary 의 loading 의 handle
SWR (lightweight alternative)
import useSWR from 'swr';
const { data, error, mutate } = useSWR(
`/api/users/${id}`,
(url) => fetch(url).then(r => r.json()),
{ revalidateOnFocus: true, dedupingInterval: 2000 }
);
Server Components data (Next.js 15 / RSC)
// app/users/[id]/page.tsx — runs on server
async function UserPage({ params }: { params: { id: string } }) {
const user = await fetch(`https://api/users/${params.id}`, {
next: { revalidate: 60, tags: [`user-${params.id}`] }
}).then(r => r.json());
return <Profile user={user} />;
}
매 결정 기준
| 상황 | Approach |
|---|---|
| React app | TanStack Query v5 |
| Next.js App Router | RSC fetch + Server Actions + tag invalidation |
| Redux app | RTK Query (Redux 의 통합) |
| 매 minimal bundle | SWR (~5KB) |
| 매 GraphQL | Apollo Client / urql |
| 매 simple form fetch | native fetch + useState 의 OK |
기본값: 매 React + REST → TanStack Query, 매 Next.js → RSC fetch.
🔗 Graph
- 부모: State Management
- 응용: Optimistic UI · Infinite Scroll · React Server Components — 경계 의식
- Adjacent: AbortController
🤖 LLM 활용
언제: cache key design 의 review, invalidation strategy 의 plan, race condition 의 debug. 언제 X: real-time data (WebSocket/SSE 의 substitute).
❌ 안티패턴
useEffect + fetch: 매 race condition, 매 no dedup, 매 no cache — 매 library 의 use.- Global Redux 에 server state: 매 manual cache management — 매 RTK Query 의 use.
- Polling 의 abuse: 매 SSE/WebSocket 의 substitute.
enabled: !!id누락: 매 undefined 의 fetch — false positive.
🧪 검증 / 중복
- Verified (TanStack Query v5 docs, Vercel SWR docs, Next.js 15 data fetching).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — TanStack Query v5 + RSC + optimistic update 의 정리 |