Skip to main content

Download settings for the SDK

The SDK creates a cache folder to temporarily store files that are actively being worked with. Files contained within the cache folder do not require re-download from the SDK when new sessions or objects are created.

The cache comes with reasonable default values, but it may also be configured using the SDK configuration file or environment variables. The cache has the following properties:

PropertyDescriptionDefault
Cache directoryThe location of the cache directory.See default directory.
Maximum cache sizeThe maximum amount of data retained in the cache. Past this limit, the SDK will return a warning when initialised.5 GB
Cache persistenceHow cached data is retained. When set to persistent, the cache is retained between separate SDK sessions. When set to session, the cache will be cleared once the current SDK session is ended.persistent
Maximum unused daysControls the cache cleaning logic. Cached files that have not been accessed in this many days will be removed.7 days
Maximum days oldControls the cache cleaning logic. Cached files downloaded this many days ago will be removed.30 days

Interacting with the cache manager

The cache manager can be accessed through the current sdk object to get a summary of the current cache and perform maintenance.

MethodDescription
tsdk.cache_manager.cache_dirReturns the current cache directory.
tsdk.cache_manager.print_cache_info()Prints cache directory, number of files, size, etc.
tsdk.cache_manager.cache_cleanup()Runs the cache cleanup routine following current configuration rules.
tsdk.cache_manager.purge_cache()Removes all contents from the cache.

Default cache directory

The default cache directory differs by operating system, listed below.

  • Linux - %HOME%/.cache/treble
  • Windows - %HOME%\AppData\Local\treble\cache
  • MacOs - %HOME%/Library/Caches/treble/cache

Where %HOME% is the home directory.

Cache configuration

Custom cache settings may be defined using either of the following options.

Environment variables

Setting the following environmental variables allows you to control the cache settings within an instance of the SDK:

TSDK_CACHE_DIR = 'path/to/directory' # Set cache directory, as a path
TSDK_MAX_CACHE_SIZE_KB = 1024 # Set the maximum size in kilobytes
TSDK_CACHE_PERSISTENCE = 'persistent' # persistent or session
TSDK_CACHE_CLEANUP_MAX_DAYS_UNUSED = 2 # integer days
TSDK_CACHE_CLEANUP_MAX_DAYS_OLD = 35 # integer days

TSDK_CONFIG_PATH = 'path/to/config/file.toml' # Set the path to the optional configuration file

Configuration file

The SDK cache may be controlled by a file rather than with environmental variables. The SDK will automatically search for the configuration files on the following paths, dependent on the operating system:

  • Linux - %HOME%/.config/treble/tsdk_config.toml
  • Windows - %HOME%\Appdata\Local\treble\tsdk\tsdk_config.toml and %HOME%\AppData\Roaming\treble\tsdk\tsdk_config.toml
  • MacOs - %HOME%/Library/Application Support/treble/tsdk_config.toml

Where %HOME% is the current user's home directory.

You can also specify a custom path to the SDK config file by using the TSDK_CONFIG_PATH environment variable.

Example file structure

An example of a config file:

[TSDK]
cache_dir: "/tmp/my/cache"
max_cache_size_kb: 1024
cache_persistence: "SESSION"
default_log_level: "INFO"
cache_cleanup_max_days_unused: 7
cache_cleanup_max_days_old: 30