사이트맵을 리소스 단위로 영속화(sitemap_urls)해 진정한 증분 갱신과 도메인 재쿼리 없는 파일 재작성을 구현했다. 리소스 공개/비공개/삭제 시 해당 항목만 색인이 갱신되고, 관리자=full·스케줄러=auto·리소스 변경=증분으로 동작한다. - sitemap_urls 마이그레이션 + SitemapUrl 모델. loc(2048) 를 unique 에 직접 넣으면 InnoDB 키 길이를 초과하므로 loc_hash(sha256) 컬럼을 identity 로 사용 - SitemapUrlRepository(멱등 upsert / remove / 스트리밍) + SitemapIndexer (+ 제3자용 sitemap.index.collect_for_resource 필터 훅) - 4 리스너 재배선: 공개→색인 / 비공개·삭제→색인 해제 + 재생성 잡 디바운스 디스패치. 3 기여자가 resource_type/resource_id 를 함께 emit 해 전체·증분 identity 를 일치 - 재생성 모드를 SitemapGenerationMode Backed Enum 으로 통일(Command→Job→Manager) - seo:generate-sitemap 에 --rebuild / --mode 옵션 추가
62 lines
2.5 KiB
PHP
62 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Contracts\Repositories;
|
|
|
|
use App\Models\SitemapUrl;
|
|
|
|
/**
|
|
* 사이트맵 URL 저장소 인터페이스
|
|
*
|
|
* sitemap_urls 테이블에 대한 리소스 단위 증분 갱신과 스트리밍 조회를 제공합니다.
|
|
* 리스너는 SitemapIndexer 를 경유해 이 저장소를 사용하며(직접 Model/DB 접근 금지),
|
|
* 전체 재생성/증분 파일 작성은 이 저장소의 스트림을 소비합니다.
|
|
*/
|
|
interface SitemapUrlRepositoryInterface
|
|
{
|
|
/**
|
|
* 한 리소스의 사이트맵 URL 행을 현재 상태로 대체합니다(멱등).
|
|
*
|
|
* (resource_type, resource_id) 로 기존 행을 제거한 뒤 전달된 항목을 삽입하므로,
|
|
* 같은 입력으로 여러 번 호출해도 테이블 내용이 동일합니다(loc 변경/슬러그 변경 흡수).
|
|
*
|
|
* @param string $type 리소스 유형
|
|
* @param string $id 리소스 PK (문자열)
|
|
* @param array<int, array{loc: string, contributor: string, lastmod?: mixed, changefreq?: ?string, priority?: ?float}> $entries URL 항목
|
|
*/
|
|
public function upsertForResource(string $type, string $id, array $entries): void;
|
|
|
|
/**
|
|
* 한 리소스의 사이트맵 URL 행을 모두 제거합니다(비공개/삭제 시).
|
|
*
|
|
* @param string $type 리소스 유형
|
|
* @param string $id 리소스 PK (문자열)
|
|
*/
|
|
public function removeForResource(string $type, string $id): void;
|
|
|
|
/**
|
|
* 공개(is_visible) URL 을 id 순으로 스트리밍합니다(유계 메모리).
|
|
*
|
|
* @param string|null $contributor 기여자 식별자로 스코핑 (null = 전체)
|
|
* @return iterable<int, SitemapUrl> URL 순회자
|
|
*/
|
|
public function streamVisible(?string $contributor = null): iterable;
|
|
|
|
/**
|
|
* 공개(is_visible) URL 총 개수를 반환합니다.
|
|
*
|
|
* @return int 공개 URL 수
|
|
*/
|
|
public function countVisible(): int;
|
|
|
|
/**
|
|
* 한 기여자의 모든 사이트맵 URL 행을 전량 대체합니다(전체 재생성).
|
|
*
|
|
* 기여자 스코프로 기존 행을 제거한 뒤 스트림을 청크 삽입하여
|
|
* 대용량에서도 메모리를 유계로 유지합니다.
|
|
*
|
|
* @param string $contributor 기여자 식별자
|
|
* @param iterable<int, array{loc: string, resource_type?: string, resource_id?: mixed, lastmod?: mixed, changefreq?: ?string, priority?: ?float}> $entries URL 항목 스트림
|
|
*/
|
|
public function replaceAllForContributor(string $contributor, iterable $entries): void;
|
|
}
|