expiringsqlitedict

class expiringsqlitedict.Connection(connection: ~sqlite3.Connection, serializer: ~typing.Any = <module 'json' from '/home/docs/.pyenv/versions/3.7.9/lib/python3.7/json/__init__.py'>, lifespan: ~datetime.timedelta = datetime.timedelta(days=7), table: str = 'expiringsqlitedict')

The actual connection object, as a MutableMapping[str, Any].

Items are expired when a value is inserted or updated. Deletion or postponement does not expire items.

clear() None

Delete all items from the table.

items() Iterator[Tuple[str, Any]]

Iterate over keys and values in the table.

keys() Iterator[str]

Iterate over keys in the table.

property lifespan: timedelta

The current lifespan.

Changing this will change the calculated expiration time of future set items. It will not retroactively apply to existing items unless you explicitly postpone them.

postpone(key: str) None

Push back the expiration date of the given entry, if it exists.

postpone_all() None

Push back the expiration date of all entries at once.

values() Iterator[Any]

Iterate over values in the table.

expiringsqlitedict.SimpleSqliteDict(*args, serializer: ~typing.Any = <module 'json' from '/home/docs/.pyenv/versions/3.7.9/lib/python3.7/json/__init__.py'>, lifespan: ~datetime.timedelta = datetime.timedelta(days=7), isolation_level: ~typing.Optional[str] = None, table: str = 'expiringsqlitedict', **kwargs) Connection

Set up the sqlite dictionary manager as a non-contextmanager with a finalizer.

If you set the isolation_level, you will be responsible for calling d.connection.commit() and d.connection.rollback() appropriately.

class expiringsqlitedict.SqliteDict(*args, serializer: ~typing.Any = <module 'json' from '/home/docs/.pyenv/versions/3.7.9/lib/python3.7/json/__init__.py'>, lifespan: ~datetime.timedelta = datetime.timedelta(days=7), transaction: str = 'IMMEDIATE', table: str = 'expiringsqlitedict', **kwargs)

Set up the sqlite dictionary manager.

This needs to be used as a context manager. It will not operate at all otherwise. args and kwargs are directly passed to sqlite3.connect. Use these to customize your connection, such as making it read-only.

This is lazy, and won’t even open the database until it is entered. It may be re-opened after it has closed.

property lifespan: timedelta

The current lifespan.

Changing this will change the calculated expiration time of future set items. It will not retroactively apply to existing items unless you explicitly postpone them.