auto-claude: subtask-1-1 - Add maxSize parameter and access tracking to Cache
This commit is contained in:
@@ -0,0 +1,227 @@
|
|||||||
|
{
|
||||||
|
"base_commands": [
|
||||||
|
".",
|
||||||
|
"[",
|
||||||
|
"[[",
|
||||||
|
"ag",
|
||||||
|
"awk",
|
||||||
|
"basename",
|
||||||
|
"bash",
|
||||||
|
"bc",
|
||||||
|
"break",
|
||||||
|
"cat",
|
||||||
|
"cd",
|
||||||
|
"chmod",
|
||||||
|
"clear",
|
||||||
|
"cmp",
|
||||||
|
"column",
|
||||||
|
"comm",
|
||||||
|
"command",
|
||||||
|
"continue",
|
||||||
|
"cp",
|
||||||
|
"curl",
|
||||||
|
"cut",
|
||||||
|
"date",
|
||||||
|
"df",
|
||||||
|
"diff",
|
||||||
|
"dig",
|
||||||
|
"dirname",
|
||||||
|
"du",
|
||||||
|
"echo",
|
||||||
|
"egrep",
|
||||||
|
"env",
|
||||||
|
"eval",
|
||||||
|
"exec",
|
||||||
|
"exit",
|
||||||
|
"expand",
|
||||||
|
"export",
|
||||||
|
"expr",
|
||||||
|
"false",
|
||||||
|
"fd",
|
||||||
|
"fgrep",
|
||||||
|
"file",
|
||||||
|
"find",
|
||||||
|
"fmt",
|
||||||
|
"fold",
|
||||||
|
"gawk",
|
||||||
|
"gh",
|
||||||
|
"git",
|
||||||
|
"grep",
|
||||||
|
"gunzip",
|
||||||
|
"gzip",
|
||||||
|
"head",
|
||||||
|
"help",
|
||||||
|
"host",
|
||||||
|
"iconv",
|
||||||
|
"id",
|
||||||
|
"jobs",
|
||||||
|
"join",
|
||||||
|
"jq",
|
||||||
|
"kill",
|
||||||
|
"killall",
|
||||||
|
"less",
|
||||||
|
"let",
|
||||||
|
"ln",
|
||||||
|
"ls",
|
||||||
|
"lsof",
|
||||||
|
"man",
|
||||||
|
"mkdir",
|
||||||
|
"mktemp",
|
||||||
|
"more",
|
||||||
|
"mv",
|
||||||
|
"nl",
|
||||||
|
"paste",
|
||||||
|
"pgrep",
|
||||||
|
"ping",
|
||||||
|
"pkill",
|
||||||
|
"popd",
|
||||||
|
"printenv",
|
||||||
|
"printf",
|
||||||
|
"ps",
|
||||||
|
"pushd",
|
||||||
|
"pwd",
|
||||||
|
"read",
|
||||||
|
"readlink",
|
||||||
|
"realpath",
|
||||||
|
"reset",
|
||||||
|
"return",
|
||||||
|
"rev",
|
||||||
|
"rg",
|
||||||
|
"rm",
|
||||||
|
"rmdir",
|
||||||
|
"sed",
|
||||||
|
"seq",
|
||||||
|
"set",
|
||||||
|
"sh",
|
||||||
|
"shuf",
|
||||||
|
"sleep",
|
||||||
|
"sort",
|
||||||
|
"source",
|
||||||
|
"split",
|
||||||
|
"stat",
|
||||||
|
"tail",
|
||||||
|
"tar",
|
||||||
|
"tee",
|
||||||
|
"test",
|
||||||
|
"time",
|
||||||
|
"timeout",
|
||||||
|
"touch",
|
||||||
|
"tr",
|
||||||
|
"tree",
|
||||||
|
"true",
|
||||||
|
"type",
|
||||||
|
"uname",
|
||||||
|
"unexpand",
|
||||||
|
"uniq",
|
||||||
|
"unset",
|
||||||
|
"unzip",
|
||||||
|
"watch",
|
||||||
|
"wc",
|
||||||
|
"wget",
|
||||||
|
"whereis",
|
||||||
|
"which",
|
||||||
|
"whoami",
|
||||||
|
"xargs",
|
||||||
|
"yes",
|
||||||
|
"yq",
|
||||||
|
"zip",
|
||||||
|
"zsh"
|
||||||
|
],
|
||||||
|
"stack_commands": [
|
||||||
|
"ar",
|
||||||
|
"clang",
|
||||||
|
"clang++",
|
||||||
|
"cmake",
|
||||||
|
"composer",
|
||||||
|
"dive",
|
||||||
|
"docker",
|
||||||
|
"docker-buildx",
|
||||||
|
"docker-compose",
|
||||||
|
"dockerfile",
|
||||||
|
"eslint",
|
||||||
|
"g++",
|
||||||
|
"gcc",
|
||||||
|
"ipython",
|
||||||
|
"jupyter",
|
||||||
|
"ld",
|
||||||
|
"make",
|
||||||
|
"meson",
|
||||||
|
"next",
|
||||||
|
"ninja",
|
||||||
|
"nm",
|
||||||
|
"node",
|
||||||
|
"notebook",
|
||||||
|
"npm",
|
||||||
|
"npx",
|
||||||
|
"objdump",
|
||||||
|
"pdb",
|
||||||
|
"php",
|
||||||
|
"pip",
|
||||||
|
"pip3",
|
||||||
|
"pipx",
|
||||||
|
"pnpm",
|
||||||
|
"pnpx",
|
||||||
|
"pudb",
|
||||||
|
"python",
|
||||||
|
"python3",
|
||||||
|
"react-scripts",
|
||||||
|
"strip",
|
||||||
|
"ts-node",
|
||||||
|
"tsc",
|
||||||
|
"tsx",
|
||||||
|
"vitest"
|
||||||
|
],
|
||||||
|
"script_commands": [
|
||||||
|
"bun",
|
||||||
|
"npm",
|
||||||
|
"pnpm",
|
||||||
|
"yarn"
|
||||||
|
],
|
||||||
|
"custom_commands": [],
|
||||||
|
"detected_stack": {
|
||||||
|
"languages": [
|
||||||
|
"python",
|
||||||
|
"javascript",
|
||||||
|
"typescript",
|
||||||
|
"php",
|
||||||
|
"c"
|
||||||
|
],
|
||||||
|
"package_managers": [
|
||||||
|
"pnpm"
|
||||||
|
],
|
||||||
|
"frameworks": [
|
||||||
|
"nextjs",
|
||||||
|
"react",
|
||||||
|
"vitest",
|
||||||
|
"eslint"
|
||||||
|
],
|
||||||
|
"databases": [],
|
||||||
|
"infrastructure": [
|
||||||
|
"docker"
|
||||||
|
],
|
||||||
|
"cloud_providers": [],
|
||||||
|
"code_quality_tools": [],
|
||||||
|
"version_managers": []
|
||||||
|
},
|
||||||
|
"custom_scripts": {
|
||||||
|
"npm_scripts": [
|
||||||
|
"dev",
|
||||||
|
"build",
|
||||||
|
"start",
|
||||||
|
"lint",
|
||||||
|
"build:images",
|
||||||
|
"generate:images",
|
||||||
|
"generate:images:dry",
|
||||||
|
"test",
|
||||||
|
"test:coverage"
|
||||||
|
],
|
||||||
|
"make_targets": [],
|
||||||
|
"poetry_scripts": [],
|
||||||
|
"cargo_aliases": [],
|
||||||
|
"shell_scripts": []
|
||||||
|
},
|
||||||
|
"project_dir": "C:\\Users\\damja\\WebstormProjects\\Portfolio",
|
||||||
|
"created_at": "2026-01-22T15:28:38.237190",
|
||||||
|
"project_hash": "c4ad399e16be367eb4e6b076fe1d9ee3",
|
||||||
|
"inherited_from": "C:\\Users\\damja\\WebstormProjects\\Portfolio"
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"active": true,
|
||||||
|
"spec": "007-add-cache-size-limit-with-lru-eviction",
|
||||||
|
"state": "planning",
|
||||||
|
"subtasks": {
|
||||||
|
"completed": 0,
|
||||||
|
"total": 0,
|
||||||
|
"in_progress": 1,
|
||||||
|
"failed": 0
|
||||||
|
},
|
||||||
|
"phase": {
|
||||||
|
"current": "Enhance Cache Class with LRU",
|
||||||
|
"id": null,
|
||||||
|
"total": 3
|
||||||
|
},
|
||||||
|
"workers": {
|
||||||
|
"active": 0,
|
||||||
|
"max": 1
|
||||||
|
},
|
||||||
|
"session": {
|
||||||
|
"number": 2,
|
||||||
|
"started_at": "2026-01-25T06:26:23.762940"
|
||||||
|
},
|
||||||
|
"last_update": "2026-01-25T06:30:31.590680"
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"sandbox": {
|
||||||
|
"enabled": true,
|
||||||
|
"autoAllowBashIfSandboxed": true
|
||||||
|
},
|
||||||
|
"permissions": {
|
||||||
|
"defaultMode": "acceptEdits",
|
||||||
|
"allow": [
|
||||||
|
"Read(./**)",
|
||||||
|
"Write(./**)",
|
||||||
|
"Edit(./**)",
|
||||||
|
"Glob(./**)",
|
||||||
|
"Grep(./**)",
|
||||||
|
"Read(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude\\worktrees\\tasks\\007-add-cache-size-limit-with-lru-eviction/**)",
|
||||||
|
"Write(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude\\worktrees\\tasks\\007-add-cache-size-limit-with-lru-eviction/**)",
|
||||||
|
"Edit(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude\\worktrees\\tasks\\007-add-cache-size-limit-with-lru-eviction/**)",
|
||||||
|
"Glob(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude\\worktrees\\tasks\\007-add-cache-size-limit-with-lru-eviction/**)",
|
||||||
|
"Grep(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude\\worktrees\\tasks\\007-add-cache-size-limit-with-lru-eviction/**)",
|
||||||
|
"Read(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude\\worktrees\\tasks\\007-add-cache-size-limit-with-lru-eviction\\.auto-claude\\specs\\007-add-cache-size-limit-with-lru-eviction/**)",
|
||||||
|
"Write(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude\\worktrees\\tasks\\007-add-cache-size-limit-with-lru-eviction\\.auto-claude\\specs\\007-add-cache-size-limit-with-lru-eviction/**)",
|
||||||
|
"Edit(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude\\worktrees\\tasks\\007-add-cache-size-limit-with-lru-eviction\\.auto-claude\\specs\\007-add-cache-size-limit-with-lru-eviction/**)",
|
||||||
|
"Read(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude/**)",
|
||||||
|
"Write(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude/**)",
|
||||||
|
"Edit(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude/**)",
|
||||||
|
"Glob(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude/**)",
|
||||||
|
"Grep(C:\\Users\\damja\\WebstormProjects\\Portfolio\\.auto-claude/**)",
|
||||||
|
"Bash(*)",
|
||||||
|
"WebFetch(*)",
|
||||||
|
"WebSearch(*)",
|
||||||
|
"mcp__context7__resolve-library-id(*)",
|
||||||
|
"mcp__context7__get-library-docs(*)",
|
||||||
|
"mcp__graphiti-memory__search_nodes(*)",
|
||||||
|
"mcp__graphiti-memory__search_facts(*)",
|
||||||
|
"mcp__graphiti-memory__add_episode(*)",
|
||||||
|
"mcp__graphiti-memory__get_episodes(*)",
|
||||||
|
"mcp__graphiti-memory__get_entity_edge(*)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-1
@@ -81,4 +81,7 @@ supabase/.temp/
|
|||||||
.history/
|
.history/
|
||||||
|
|
||||||
# Source images (originals before optimization)
|
# Source images (originals before optimization)
|
||||||
source-images/
|
source-images/
|
||||||
|
|
||||||
|
# Auto Claude data directory
|
||||||
|
.auto-claude/
|
||||||
|
|||||||
+36
-6
@@ -2,35 +2,65 @@ type CacheItem<T> = {
|
|||||||
value: T;
|
value: T;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
ttl: number;
|
ttl: number;
|
||||||
|
lastAccessed: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Cache {
|
class Cache {
|
||||||
private storage: Map<string, CacheItem<any>>;
|
private storage: Map<string, CacheItem<any>>;
|
||||||
private readonly defaultTTL: number;
|
private readonly defaultTTL: number;
|
||||||
|
private readonly maxSize?: number;
|
||||||
|
|
||||||
constructor(defaultTTL = 5 * 60 * 1000) { // 5 minutes default TTL
|
constructor(defaultTTL = 5 * 60 * 1000, maxSize?: number) { // 5 minutes default TTL
|
||||||
this.storage = new Map();
|
this.storage = new Map();
|
||||||
this.defaultTTL = defaultTTL;
|
this.defaultTTL = defaultTTL;
|
||||||
|
this.maxSize = maxSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
set<T>(key: string, value: T, ttl = this.defaultTTL): void {
|
set<T>(key: string, value: T, ttl = this.defaultTTL): void {
|
||||||
|
const now = Date.now();
|
||||||
|
|
||||||
|
// If maxSize is set and cache is full, evict least recently used item
|
||||||
|
if (this.maxSize && this.storage.size >= this.maxSize && !this.storage.has(key)) {
|
||||||
|
this.evictLRU();
|
||||||
|
}
|
||||||
|
|
||||||
this.storage.set(key, {
|
this.storage.set(key, {
|
||||||
value,
|
value,
|
||||||
timestamp: Date.now(),
|
timestamp: now,
|
||||||
ttl
|
ttl,
|
||||||
|
lastAccessed: now
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private evictLRU(): void {
|
||||||
|
let lruKey: string | null = null;
|
||||||
|
let lruTime = Infinity;
|
||||||
|
|
||||||
|
for (const [key, item] of this.storage.entries()) {
|
||||||
|
if (item.lastAccessed < lruTime) {
|
||||||
|
lruTime = item.lastAccessed;
|
||||||
|
lruKey = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lruKey) {
|
||||||
|
this.storage.delete(lruKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get<T>(key: string): T | null {
|
get<T>(key: string): T | null {
|
||||||
const item = this.storage.get(key);
|
const item = this.storage.get(key);
|
||||||
|
|
||||||
if (!item) return null;
|
if (!item) return null;
|
||||||
|
|
||||||
if (Date.now() > item.timestamp + item.ttl) {
|
if (Date.now() > item.timestamp + item.ttl) {
|
||||||
this.storage.delete(key);
|
this.storage.delete(key);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update last accessed time for LRU tracking
|
||||||
|
item.lastAccessed = Date.now();
|
||||||
|
|
||||||
return item.value;
|
return item.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user