SQLiteCache

data class SQLiteCache(val path: Path, val expiry: Int? = null)

A simple SQLite-based caching mechanism for storing and retrieving HTTP query results.

The SQLiteCache class provides methods to persist query results, retrieve them later, and automatically clean up expired entries based on a configurable expiry period.

Constructors

Link copied to clipboard
constructor(path: Path, expiry: Int? = null)

Initializes the SQLite cache, creating the necessary table and performing cleanup for expired entries.

Properties

Link copied to clipboard
val expiry: Int? = null

The number of days before cached entries expire. If null, entries will not expire.

Link copied to clipboard
val path: Path

The file path to the SQLite database file.

Functions

Link copied to clipboard
fun cleanup()

Cleans up expired entries in the cache.

Link copied to clipboard
fun delete(url: String)

Deletes a cached response for a given URL.

Link copied to clipboard
fun insert(url: String, response: String)

Inserts a new cached response for a given URL.

Link copied to clipboard
fun select(url: String): String?

Selects a cached response for a given URL.