Taos API Reference
    Preparing search index...

    Class DataSourceLog

    Optional instrumentation of data-source loads, for diagnosing what's hitting the network vs. the persistent cache. DISABLED by default: while enabled is false every record call early-returns, so the only cost on the load path is a single boolean test and nothing is retained.

    When enabled it counts cacheable (binary) requests served from cache vs. total, and keeps the last maxEntries NETWORK loads in a ring buffer (cache hits are counted only, not retained, to keep it light). Subscribe for change notifications to drive a view; the notify is coalesced by the view (rAF), not here.

    Index

    Constructors

    Properties

    enabled: boolean = false

    Master switch. Off = zero retention and (effectively) zero overhead.

    maxEntries: number = 1000

    Cap on retained network entries (oldest dropped past this).

    cacheHits: number = 0

    Cacheable (binary) requests served from the persistent cache since the last clear.

    cacheableTotal: number = 0

    Cacheable (binary) requests since the last clear (cache hits + network misses).

    bytesDownloaded: number = 0

    Total bytes downloaded over the network (not served from cache) since the last clear — i.e. the actual data pulled from data sources (≈ quota usage).

    bytesFromCache: number = 0

    Total bytes served from the persistent cache since the last clear (network saved).

    cacheAvailable: boolean = true

    Whether the persistent Cache Storage is usable (false outside a secure context — e.g. the dev server opened over a LAN IP rather than localhost/https). When false NOTHING persists across reloads, regardless of keys.

    cacheWrites: number = 0

    Tiles successfully written to the persistent cache since the last clear.

    cacheWriteErrors: number = 0

    Failed persistent-cache writes since the last clear (quota, or a Response the Cache API refuses). If this climbs while cacheWrites stays 0, writes are the reason nothing persists; the first failure is logged to the console with its cause.

    Accessors

    Methods

    • Records a load downloaded from a data source over the network. cacheable marks loads that go through the persistent cache (so they count toward the hit ratio); non-cacheable loads (root.json / layer.json) are listed but excluded from the ratio.

      Parameters

      • source: string
      • url: string
      • what: "json" | "binary"
      • bytes: number
      • cacheable: boolean

      Returns void

    • Records a request served from the persistent cache.

      Parameters

      • source: string
      • url: string
      • bytes: number
      • what: "json" | "binary"

      Returns void

    • Records a failed persistent-cache write; console-logs the first cause so a write that's silently defeating persistence (Vary header, quota, …) is visible. Counts regardless of enabled so the tally is meaningful whenever the view opens.

      Parameters

      • err: unknown

      Returns void

    • Subscribes to changes; returns an unsubscribe fn.

      Parameters

      • fn: LogListener

      Returns () => void