Control local data

The Node SDK stores downloaded data locally and removes older items when the cache reaches its limit.

Documentation navigation

Configure the cache

cache.ts
import { CacheClient } from "@embed-earth/sdk-test/node";

const cache = new CacheClient("./.e2-cache");
await cache.setLimit("2GB");
const info = await cache.list();
console.log(info.directory, info.usedBytes);
The default directory is ~/.e2/cache. The minimum configured size is 1GB. Size strings support B, KB, MB, GB, TB and their binary KiB, MiB, GiB, TiB forms.

Cache methods

MethodBehavior
setLimit(value)Set the size limit and evict oldest entries if needed.
getLimit()Return the configured byte limit.
list()Return directory, limit, used bytes, and entries.
remove(key)Delete an entry by key, data ID, or filename.
clear()Delete all tracked files and return the count.

CLI equivalent

terminal
e2 cache set 5GB
e2 cache list
e2 cache delete <snapshot-id>
e2 cache clear

When the cache is full, E2 removes the least recently used item. A download larger than the configured limit is rejected.