Features
Cache And Storage
Netpress now exposes cache and storage as shared core facades. The starter configures them during boot, so application code can import the framework helpers directly instead of rebuilding app-local services.
Quick Example
import { cache, storage } from "@admicaa/netpress";
await cache.set("users:count", 42);
await cache.driver().set("users:active", 18);
const avatarPath = await storage.put("avatars/ada.txt", "hello");
const publicUrl = storage.driver().url(avatarPath);
How The Starter Boots Them
AppServiceProvider reads config/cache.js and config/storage.js, then configures the shared core facades during boot.
That gives you:
cache.get(),cache.set(),cache.put(),cache.remember(),cache.forget(),cache.flush()cache.driver(name)andcache.store(name)cache.tags([...])storage.put(),storage.get(),storage.delete(),storage.exists(),storage.url(),storage.upload()storage.driver(name)andstorage.disk(name)
The starter keeps app/Services/CacheService.js and app/Services/StorageService.js only as thin compatibility re-exports of those core helpers.
Cache Configuration
// config/cache.js
export default {
driver: process.env.CACHE_DRIVER || "redis",
prefix: process.env.CACHE_PREFIX || "netpress_cache:",
ttl: parseInt(process.env.CACHE_TTL, 10) || 3600,
redis: {
url: process.env.REDIS_URL || "redis://127.0.0.1:6379",
},
file: {
path: process.env.CACHE_FILE_PATH || "./storage/cache",
},
};
Supported cache drivers:
memoryfor tests and local fallbacksfilefor simple filesystem-backed cache storageredisfor shared process-safe cache storage
Example usage:
import { cache } from "@admicaa/netpress";
const profile = await cache.remember("user:1:profile", 300, async () => {
return {
name: "Ada",
plan: "pro",
};
});
await cache.tags(["users", "profiles"]).set("user:1", profile, 300);
Storage Configuration
// config/storage.js
export default {
default: process.env.STORAGE_DRIVER || "local",
disks: {
local: {
driver: "local",
root: process.env.STORAGE_LOCAL_ROOT || "./storage/app",
url: "/storage",
},
s3: {
driver: "s3",
bucket: process.env.AWS_BUCKET || "",
region: process.env.AWS_REGION || "us-east-1",
accessKeyId: process.env.AWS_ACCESS_KEY_ID || "",
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || "",
},
},
};
Example usage:
import { storage } from "@admicaa/netpress";
await storage.put("reports/today.json", JSON.stringify({ ok: true }));
const report = await storage.driver().get("reports/today.json");
const exists = await storage.exists("reports/today.json");
const url = storage.url("reports/today.json");
storage.upload(field) returns the upload middleware for the active disk. Local disks stream directly to the filesystem. S3 uses in-memory upload buffering so your controller can decide how to persist the file.
Notes
cache.driver()andstorage.driver()are the clearest way to switch stores or disks explicitly.cache:clearandstorage:linkuse the same shared configuration the runtime uses at request time.- Redis support depends on
ioredis. - S3 support depends on
@aws-sdk/client-s3.