Sign in

    mizchi/sol/isr does not have a README file

    ISRManifest

    ISR manifest loaded from _luna/isr.json

    ISRPageMeta

    ISR page entry from manifest

    ISRCache

    pub(open) trait ISRCache {
    fn get(Self, String) -> CacheEntry?
    fn put(Self, String, CacheEntry) -> Unit
    fn delete(Self, String) -> Unit
    fn schedule_revalidation(Self, async () -> Unit) -> Unit
    }

    ISR cache storage abstraction Implement this trait for different backends (Memory, KV, Redis, etc.)

    CDNCacheStrategy

    pub(all) enum CDNCacheStrategy {
    CdnSwr(Int)
    Hybrid(Int, Int)
    AppIsr
    }

    CDN cache strategy for ISR pages. Controls how CDN-level caching (e.g., Cloudflare async SWR) interacts with app-level ISR caching.

    CDNCacheStrategy::cache_control

    fn CDNCacheStrategy::cache_control(self : CDNCacheStrategy, revalidate : Int) -> String

    Generate Cache-Control header value for a given strategy and revalidate interval.

    CDNCacheStrategy::header_value

    fn CDNCacheStrategy::header_value(self : CDNCacheStrategy) -> String

    Get the X-Sol-CDN-Cache header value describing this strategy.

    CacheEntry

    pub struct CacheEntry {
    html : String
    generated_at : Int64
    revalidate : Int
    }

    ISR cache entry containing rendered HTML and metadata

    CacheEntry::new

    fn CacheEntry::new(html : String, generated_at : Int64, revalidate : Int) -> CacheEntry

    Create a new cache entry

    CacheStatus

    pub enum CacheStatus {
    Fresh
    Stale
    Miss
    }

    Cache status for SWR (Stale-While-Revalidate) pattern

    ISRConfig

    pub struct ISRConfig {
    enabled : Bool
    default_revalidate : Int
    }

    ISR configuration

    ISRConfig::default

    fn ISRConfig::default() -> ISRConfig

    Default ISR configuration

    ISRHandler

    pub struct ISRHandler[Cache] {
    cache : Cache
    manifest :
    ISRManifest

    dist_dir : String
    }

    ISR handler that wraps cache and manifest

    ISRHandler::handle

    async fn[Cache : ISRCache] ISRHandler::handle(self : ISRHandler[Cache], path : String) -> (String?, Bool)

    Handle ISR request Returns (html, needs_revalidation)

    ISRHandler::new

    fn[Cache] ISRHandler::new(cache : Cache, manifest :
    ISRManifest
    , dist_dir : String) -> ISRHandler[Cache]

    Create new ISR handler

    ISRHandler::update_cache

    fn[Cache : ISRCache] ISRHandler::update_cache(self : ISRHandler[Cache], path : String, html : String) -> Unit

    Update cache after revalidation

    ISRMiddlewareConfig

    pub struct ISRMiddlewareConfig {
    dist_dir : String
    enabled : Bool
    }

    ISR middleware configuration

    ISRMiddlewareConfig::default

    Default ISR middleware configuration

    MemoryCache

    pub struct MemoryCache {
    store :
    Ref
    [Map[String, CacheEntry]]
    }

    In-memory ISR cache implementation Suitable for development and single-instance deployments Uses Ref to ensure shared state when handler is copied

    MemoryCache::new

    Create a new empty MemoryCache

    cache_key

    fn cache_key(path : String, query : Array[(String, String)]) -> String

    Generate cache key from path and query parameters Key format: "isr:{path}?{sorted_query}"

    check_status

    fn check_status(entry : CacheEntry?, now_ms : Int64) -> CacheStatus

    Check cache status based on entry and current time

    create_isr_middleware

    async fn create_isr_middleware(dist_dir : String) -> ((
    Context
    [Unit, Unit]) ->
    Promise
    [Unit]?)

    Create ISR handler for Hono Returns a function that can be used as Hono middleware

    get_isr_handler

    fn get_isr_handler() -> ISRHandler[MemoryCache]?

    Get the global ISR handler

    handle_isr_request

    async fn handle_isr_request(path : String) -> (String?, Bool)

    Handle ISR for a request path Returns Some(html) if ISR handled, None otherwise

    init_isr

    async fn init_isr(dist_dir : String) -> ISRHandler[MemoryCache]

    Initialize ISR handler (call once at server startup)

    load_manifest

    async fn load_manifest(dist_dir : String) ->
    ISRManifest

    Load ISR manifest from _luna/isr.json

    now_ms

    fn now_ms() -> Int64

    Get current time in milliseconds (Unix timestamp).

    schedule_revalidation

    fn schedule_revalidation(path : String) -> Unit

    Schedule background revalidation for a path

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io