Storage caches and sessions
Choose a namespace before using storage. Call configureStorage before the first Local or Session operation; omit it when the default fast__ prefix is suitable.
Configure the namespace at application startup
import { configureStorage } from "@fast-china/utils";
configureStorage({ prefix: "my-app:" });Configuration cannot change after activation. Do not reconfigure it on every page or request.
Store an expiring cache entry
import { Local } from "@fast-china/utils";
interface Profile {
id: number;
name: string;
}
Local.set("profile", { id: 1, name: "Fast" }, { ttlMs: 30 * 60 * 1000 });
const profile = Local.get<Profile>("profile");
if (profile !== undefined) {
console.log(profile.name);
}The generic does not validate data at runtime. Validate values from untrusted storage. Missing or expired keys are cache misses; quota and decoding errors must not be disguised as success.
Session values and cleanup
Browser Session storage can hold session-only drafts; uni-app has no corresponding backend. Use Local.remove("profile") for a single entry. Call Local.clear() only when the entire application namespace should be cleared; do not clear shared underlying storage directly.
Codec and security boundary
Per-operation crypto options must match on writes and reads. This option uses reversible Base64 obfuscation, not encryption, and must not protect secrets.
See Storage API for exact signatures, defaults, errors and platform differences. This guide maintains the workflow, not a duplicate parameter reference.
