MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / FileStateCache

Class FileStateCache

source code/utils/fileStateCache.ts:32–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 * or mixed path separators on Windows (/ vs \).
31 */
32export class FileStateCache {
33 private cache: LRUCache<string, FileState>
34
35 constructor(maxEntries: number, maxSizeBytes: number) {
36 this.cache = new LRUCache<string, FileState>({
37 max: maxEntries,
38 maxSize: maxSizeBytes,
39 sizeCalculation: value => Math.max(1, Buffer.byteLength(value.content)),
40 })
41 }
42
43 get(key: string): FileState | undefined {
44 return this.cache.get(normalize(key))
45 }
46
47 set(key: string, value: FileState): this {
48 this.cache.set(normalize(key), value)
49 return this
50 }
51
52 has(key: string): boolean {
53 return this.cache.has(normalize(key))
54 }
55
56 delete(key: string): boolean {
57 return this.cache.delete(normalize(key))
58 }
59
60 clear(): void {
61 this.cache.clear()
62 }
63
64 get size(): number {
65 return this.cache.size
66 }
67
68 get max(): number {
69 return this.cache.max
70 }
71
72 get maxSize(): number {
73 return this.cache.maxSize
74 }
75
76 get calculatedSize(): number {
77 return this.cache.calculatedSize
78 }
79
80 keys(): Generator<string> {
81 return this.cache.keys()
82 }
83
84 entries(): Generator<[string, FileState]> {
85 return this.cache.entries()
86 }
87
88 dump(): ReturnType<LRUCache<string, FileState>['dump']> {
89 return this.cache.dump()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected