@agrodt/astro-redis-cache-provider
v0.1.1
Published
Redis cache provider for Astro route caching using node-redis.
Readme
@agrodt/astro-redis-cache-provider
Custom Redis cache provider for Astro route caching,
powered by node-redis.
[!CAUTION] Disclaimer: This project is 102% generated by an LLM. The author assumes absolutely no responsibility for any consequences of using it - especially, but not limited to, the mysterious harm that may befall nearby kittens once you deploy this in production. Proceed at your own risk!
Install
pnpm add @agrodt/astro-redis-cache-providernode-redis already comes as a dependency of this package. You only need
a reachable Redis server.
Usage
// astro.config.mjs
import { defineConfig } from "astro/config";
import { redisCache } from "@agrodt/astro-redis-cache-provider/config";
export default defineConfig({
experimental: {
cache: {
provider: redisCache({
url: () => process.env.REDIS_URL,
keyPrefix: "astro:cache",
}),
},
},
});Options
type RedisCacheProviderOptions = {
url?: string | (() => string | undefined);
keyPrefix?: string;
revalidateLockTtl?: number;
ignoredVaryHeaders?: Iterable<string>;
query?: {
include?: string[];
exclude?: string[];
sort?: boolean;
};
};url: Redis URL string or runtime factory (() => string | undefined), for exampleredis://localhost:6379or() => process.env.REDIS_URL.keyPrefix: Prefix for all Redis keys. Default:astro:cache.revalidateLockTtl: Lock lifetime in seconds for stale background revalidation. Default:30.ignoredVaryHeaders: AdditionalVaryheaders to ignore during cache matching (for example["cookie"]).set-cookieis always ignored.query: Same query normalization semantics as Astro memory provider (include/excludeare mutually exclusive).
Example
See example for a runnable Astro app that
demonstrates MISS/HIT behavior and manual invalidation.
