relstorage.cache.local_database – The definition of how local cache databases are manipulated

The definition of how local cache databases are manipulated.

This is the bare bones byte-shuffling layer, it defines as little policy as possible (while keeping in mind its purpose.)

class Database(connection)[source]

Bases: abc.ABC

The database stores only one state for each object.

This should generally be the latest state found in the cache.


The returned object will iterate (zoid, was_frozen, state, tid, frequency) from most frequently used and newest, to least frequently used and oldest.

You must completely consume the returned object.


Like fetch_rows_by_priority, but returns a list instead of cursor.

abstract move_from_temp()[source]

Take rows in the temporary table and put them in the permanent table, overwriting rows for the same object that are older (based on TID)

If there is a row that is newer, then it is preserved and the temporary row is discarded.

The temporary table will be clear after this.

Returns the total number of rows that were stored into the permanent table.


Given an iterator of (oid, tid, frozen, state, frequency) values, store them in a temporary table for this session.

abstract update_checkpoints(cp0, cp1)[source]

Save these checkpoints, if they are newer than the current checkpoints.

property checkpoints

The checkpoints in the database, or None if there are none.

property oid_to_tid

A map from OID to its corresponding TID, for all the data in the database.

class SimpleQueryProperty(sql, param_names=())[source]

Bases: object

Wraps a query that returns one value in one row.