← ClaudeAtlas

delon-cache-caching-strategieslisted

Implement caching strategies using @delon/cache. Use this skill when adding memory cache, LocalStorage cache, SessionStorage cache, or cache interceptors for HTTP requests. Supports TTL-based expiration, cache invalidation, cache grouping, and persistent storage. Optimizes performance by reducing redundant API calls and database queries.
aiskillstore/marketplace · ★ 329 · API & Backend · score 82
Install: claude install-skill aiskillstore/marketplace
# @delon/cache Caching Strategies Skill This skill helps implement caching using @delon/cache library. ## Core Principles ### Cache Types - **Memory Cache**: Fast, in-memory caching (lost on page refresh) - **LocalStorage Cache**: Persistent across sessions - **SessionStorage Cache**: Persistent within session only ### Features - TTL-based expiration - Cache invalidation (manual and automatic) - Cache grouping and namespacing - HTTP request caching with interceptors - Observable support for async data ## Configuration ```typescript // src/app/app.config.ts import { ApplicationConfig } from '@angular/core'; import { provideDelonCache } from '@delon/cache'; export const appConfig: ApplicationConfig = { providers: [ provideDelonCache({ mode: 'promise', // 'promise' | 'none' request_method: 'POST', meta_key: '__cache_meta', prefix: '', expire: 3600000 // Default TTL: 1 hour (ms) }) ] }; ``` ## Cache Service ```typescript // src/app/core/services/cache.service.ts import { Injectable, inject } from '@angular/core'; import { CacheService as DelonCacheService } from '@delon/cache'; import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class CacheService { private cache = inject(DelonCacheService); /** * Set cache with key */ set<T>(key: string, value: T, options?: { type?: 'memory' | 'localStorage' | 'sessionStorage'; expire?: number; // TTL in milliseconds }): void { this.cach