@fisapool/github-cache-service
v0.1.0
Published
Efficient caching service with timeout support for API requests
Maintainers
Readme
GitHub Cache Service
A flexible and efficient caching utility for client-side applications.
Features
- In-memory cache with optional localStorage persistence
- Automatic cache expiration
- TypeScript support with generics
- Singleton instance or create your own
Installation
\\ash npm install @fisapool/github-cache-service \\
Usage
Basic Usage
\\ ypescript import { cachingService } from '@fisapool/github-cache-service';
// Store data with default options (in-memory only) cachingService.set('userData', { name: 'John', id: 123 });
// Retrieve data const userData = cachingService.get('userData'); console.log(userData); // { name: 'John', id: 123 }
// Remove item from cache cachingService.remove('userData');
// Clear entire cache cachingService.clear(); \\
With Expiration & LocalStorage
\\ ypescript // Store data with 5 minute expiration and localStorage persistence cachingService.set('userData', { name: 'John', id: 123 }, { expirationTime: 5 * 60 * 1000, // 5 minutes in milliseconds useLocalStorage: true });
// Retrieve with same options const userData = cachingService.get('userData', { useLocalStorage: true }); \\
License
MIT © fisapool
