* refactor: consolidate agent config folders into agents directory - Move .claude/skills and .claude/rules content to agents/ - Remove duplicate .cursor/ and .goose/ folders - Create symlinks from .claude/ and .cursor/ to agents/ - Convert review.mdc to quality-review-checklist.md with proper frontmatter Co-Authored-By: Claude Haiku 4.5 <[email protected]> * feat: add Cal.com APIv2 skills to agents directory Move the Cal.com API v2 skills from PR #27445 into the consolidated agents/skills/ directory structure. This includes: - SKILL.md - Main skill file with API overview - references/authentication.md - Authentication methods - references/bookings.md - Bookings API reference - references/calendars.md - Calendars API reference - references/event-types.md - Event types API reference - references/schedules.md - Schedules API reference - references/slots-availability.md - Slots and availability API reference - references/webhooks.md - Webhooks API reference Co-Authored-By: [email protected] <[email protected]> * fix: update calcom-api skill to use Claude Code frontmatter format Remove non-standard frontmatter fields (license, metadata) and keep only the Claude Code supported fields (name, description) as per the Claude Code skills specification. Co-Authored-By: [email protected] <[email protected]> * refactor: restructure calcom-api SKILL.md as index file Convert SKILL.md from a comprehensive API doc (317 lines) to a concise index file (108 lines) that references the detailed documentation in the references/ folder. This follows the Claude Code skills pattern of keeping SKILL.md focused with supporting files for detailed content. The SKILL.md now: - Provides a quick start guide with essential examples - References all 7 detailed reference docs in a table - Lists common workflows and best practices - Points to external resources Co-Authored-By: [email protected] <[email protected]> * docs: preserve deleted content in reference files Move content that was removed from SKILL.md to appropriate reference files: - Add Error Handling and Pagination sections to authentication.md - Add Organization endpoints to event-types.md - Add Core Concepts section back to SKILL.md This ensures no useful API documentation is lost during the restructuring. Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Claude Haiku 4.5 <[email protected]> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
71 lines
1.6 KiB
Markdown
71 lines
1.6 KiB
Markdown
---
|
|
title: Cache Storage API Calls
|
|
impact: LOW-MEDIUM
|
|
impactDescription: reduces expensive I/O
|
|
tags: javascript, localStorage, storage, caching, performance
|
|
---
|
|
|
|
## Cache Storage API Calls
|
|
|
|
`localStorage`, `sessionStorage`, and `document.cookie` are synchronous and expensive. Cache reads in memory.
|
|
|
|
**Incorrect (reads storage on every call):**
|
|
|
|
```typescript
|
|
function getTheme() {
|
|
return localStorage.getItem('theme') ?? 'light'
|
|
}
|
|
// Called 10 times = 10 storage reads
|
|
```
|
|
|
|
**Correct (Map cache):**
|
|
|
|
```typescript
|
|
const storageCache = new Map<string, string | null>()
|
|
|
|
function getLocalStorage(key: string) {
|
|
if (!storageCache.has(key)) {
|
|
storageCache.set(key, localStorage.getItem(key))
|
|
}
|
|
return storageCache.get(key)
|
|
}
|
|
|
|
function setLocalStorage(key: string, value: string) {
|
|
localStorage.setItem(key, value)
|
|
storageCache.set(key, value) // keep cache in sync
|
|
}
|
|
```
|
|
|
|
Use a Map (not a hook) so it works everywhere: utilities, event handlers, not just React components.
|
|
|
|
**Cookie caching:**
|
|
|
|
```typescript
|
|
let cookieCache: Record<string, string> | null = null
|
|
|
|
function getCookie(name: string) {
|
|
if (!cookieCache) {
|
|
cookieCache = Object.fromEntries(
|
|
document.cookie.split('; ').map(c => c.split('='))
|
|
)
|
|
}
|
|
return cookieCache[name]
|
|
}
|
|
```
|
|
|
|
**Important (invalidate on external changes):**
|
|
|
|
If storage can change externally (another tab, server-set cookies), invalidate cache:
|
|
|
|
```typescript
|
|
window.addEventListener('storage', (e) => {
|
|
if (e.key) storageCache.delete(e.key)
|
|
})
|
|
|
|
document.addEventListener('visibilitychange', () => {
|
|
if (document.visibilityState === 'visible') {
|
|
storageCache.clear()
|
|
}
|
|
})
|
|
```
|