From fca022decd271793a43ad80a75c8d335b6201cd8 Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Fri, 18 Apr 2025 20:11:17 -0500 Subject: [PATCH] Add caching system documentation to README --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 38a552ba..bd239e30 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,37 @@ sudo nano /boot/firmware/cmdline.txt sudo reboot ``` +## Caching System + +The LEDMatrix system includes a robust caching mechanism to optimize API calls and reduce network traffic: + +### Cache Location +- Default cache directory: `/tmp/ledmatrix_cache` +- Cache files are stored with proper permissions (755 for directories, 644 for files) +- When running as root/sudo, cache ownership is automatically adjusted to the real user + +### Cached Data Types +- Weather data (current conditions and forecasts) +- Stock prices and market data +- Stock news headlines +- NHL game information + +### Cache Behavior +- Data is cached based on update intervals defined in `config.json` +- Cache is automatically invalidated when: + - Update interval has elapsed + - Market is closed (for stock data) + - Data has changed significantly +- Failed API calls fall back to cached data when available +- Cache files use atomic operations to prevent corruption + +### Cache Management +- Cache files are automatically created and managed +- No manual intervention required +- Cache directory is created with proper permissions on first run +- Temporary files are used for safe updates +- JSON serialization handles all data types including timestamps + ### Running without Sudo (Optional) To run the display script without `sudo`, the user executing the script needs access to GPIO pins. Add the user to the `gpio` group: