cache#

Cache suitable for shards, not allowed to change because they are named after their own sha256 hash.

Classes#

AnnotatedRawShard

ShardCache

Handle caching for individual shards (not the index of shards).

Functions#

connect([dburi])

Get database connection.

Attributes#

SHARD_CACHE_NAME = 'repodata_shards.db'#
ZSTD_MAX_SHARD_SIZE = 16777216#
class AnnotatedRawShard(url: str, package: str, compressed_shard: bytes)#
url#
package#
compressed_shard#
connect(dburi='cache.db')#

Get database connection.

dburi: uri-style sqlite database filename; accepts certain ?= parameters.

class ShardCache(base: pathlib.Path, create=True)#

Handle caching for individual shards (not the index of shards).

base: directory and filename prefix for cache.

base#
__enter__()#
__exit__(exc_type, exc_val, exec_tb)#
close()#

Clean up connection. ShardCache can no longer be used after close().

copy()#

Copy cache with new connection. Useful for threads.

connect(create=True, retry=True)#
Parameters:
  • create -- if True, create table if not exists.

  • retry -- remove cache, log warning, and retry on error.

insert(raw_shard: AnnotatedRawShard)#
Parameters:
  • url -- of shard

  • package -- package name

  • raw_shard -- msgpack.zst compressed shard data

retrieve(url) conda._private.shards.typing.ShardDict | None#
retrieve_multiple(urls: list[str]) dict[str, conda._private.shards.typing.ShardDict | None]#

Query database for cached shard urls.

Return a dict of urls in cache mapping to the Shard or None if not present.

clear_cache()#

Truncate the database by removing all rows from tables

remove_cache()#

Remove the sharded cache database.