Caching
Caching of timeseries data points is supported
Usage
The timeseries.get_data_points accepts a cache boolean which enables storing and extracting data from a cache instead of getting the data from the API. By default, caching is enabled (True).
The example below shows and times
- Getting data from API
- Getting data from API and storing it in cache
- Getting data from cache
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
This behaviour assumes that the specific time series has not been cached previously
Cache expiration and clearing
The cache is set with an expiry time of 7 days. Data is now explicitly deleted after 7 days, but a new call of get_data_points will replace the existing data.
Note
Caching is related to the API call. Modified data behind the same API call will not be availble if the API call has been cached (and not expired).
Note
It is good practise to clear the cache when new data is posted
The cache can be manually cleared by the client's clear_cache() method
1 2 3 4 5 6 7 8 9 |
|
Under the hood
The SDK will establish a SQLite file (mtdb.sqlite) in a local cache folder
- C:\Users\user\AppData\Local\ for Windows
- /home/user/.cache/ for Linux,
- /Users/user/Library/Caches/ for macOS
Note
Deleting this file will remove all cached data, but not affect the modeltestSDK otherwise.