wip library to store cold objects in s3, warm objects on disk, and hot objects in memory
nodejs typescript

nvm needed to note eviction policy

nekomimi.pet df3feb08 5bc23a4a

verified
Changed files
+29
+29
README.md
··· 65 65 66 66 Writes cascade **down**. Reads bubble **up**. 67 67 68 + ## Eviction 69 + 70 + Items leave upper tiers through eviction or TTL expiration: 71 + 72 + ```typescript 73 + const storage = new TieredStorage({ 74 + tiers: { 75 + // hot: LRU eviction when size/count limits hit 76 + hot: new MemoryStorageTier({ 77 + maxSizeBytes: 100 * 1024 * 1024, 78 + maxItems: 500, 79 + }), 80 + 81 + // warm: evicts when maxSizeBytes hit, policy controls which items go 82 + warm: new DiskStorageTier({ 83 + directory: './cache', 84 + maxSizeBytes: 10 * 1024 * 1024 * 1024, 85 + evictionPolicy: 'lru', // 'lru' | 'fifo' | 'size' 86 + }), 87 + 88 + // cold: never evicts, keeps everything 89 + cold: new S3StorageTier({ bucket: 'my-bucket', region: 'us-east-1' }), 90 + }, 91 + defaultTTL: 14 * 24 * 60 * 60 * 1000, // TTL checked on read 92 + }) 93 + ``` 94 + 95 + A file that hasn't been accessed eventually gets evicted from hot (LRU), then warm (size limit + policy). Next request fetches from cold and promotes it back up. 96 + 68 97 ## API 69 98 70 99 ### `storage.get(key)`