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
···
Writes cascade **down**. Reads bubble **up**.
+
## Eviction
+
+
Items leave upper tiers through eviction or TTL expiration:
+
+
```typescript
+
const storage = new TieredStorage({
+
tiers: {
+
// hot: LRU eviction when size/count limits hit
+
hot: new MemoryStorageTier({
+
maxSizeBytes: 100 * 1024 * 1024,
+
maxItems: 500,
+
}),
+
+
// warm: evicts when maxSizeBytes hit, policy controls which items go
+
warm: new DiskStorageTier({
+
directory: './cache',
+
maxSizeBytes: 10 * 1024 * 1024 * 1024,
+
evictionPolicy: 'lru', // 'lru' | 'fifo' | 'size'
+
}),
+
+
// cold: never evicts, keeps everything
+
cold: new S3StorageTier({ bucket: 'my-bucket', region: 'us-east-1' }),
+
},
+
defaultTTL: 14 * 24 * 60 * 60 * 1000, // TTL checked on read
+
})
+
```
+
+
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.
+
## API
### `storage.get(key)`