Skip to main content

Cache.checkpoint()

Copy the write-ahead log into the database and truncate it to zero.

Usage

Source

Cache.checkpoint(
    *,
    timeout=None,
)

With readers in other processes, a burst of writes can leave the log much larger than the database. Call this when a short pause suits the app: at shutdown, in a maintenance job, or after a large clear(). close() also does it for a log left large.

Parameters

timeout: float | None = None
Seconds to keep retrying while other processes or a pending fork are busy (default: the cache’s timeout).

Returns

bool

True if the log was reset, False if readers or writers in other processes, or a

pending fork, kept it busy. It never raises for a busy database.

Examples

cache.checkpoint()   # at shutdown, or after a big fill; False means "still busy, try later"