Skip to content

Caching

Brad White edited this page Apr 8, 2017 · 5 revisions

Caching in Tincr

This section attempts to explain Tincr's caching structure and justify the design decisions made.

Tincr provides an in-memory database that provides quick and easy look-up of static information which would otherwise be expensive to query from Vivado. The tables of this database may or may not be persisted to disk, depending on how that table was defined.

Rather than load the entire database into memory when the package is loaded, Tincr instead loads each table the first it is requested. The table is then kept in memory until either the Vivado session is ended, or the ::tincr::cache::free is called on the cache.

Tincr has no restrictions on the type used to store a table, though it is recommended to use types that can have low access times and are easily serialized. For these reasons, many of the tables which come prepackaged with Tincr are implemented via the array construct, which has O(1) access, can be dumped to file using the puts command, and read from file using the read command.

Each cache has four scripts that can be implemented to control its behavior:

  1. Path: Required Returns a list of strings that make a "path" to the cache. This list is used to create the cache's namespace and a file path if data persistence is employed.
  2. Generate: Optional Populates the cache from scratch.
  3. Save Optional Persists the cache to disk.
  4. Load Optional Restores the cache from disk.
Clone this wiki locally