📢 Hivemind New Optimizations
GitHub Pull Request Summary
https://github.com/steemit/hivemind/pull/360
Main Problem
The pull request aims to improve the performance and maintainability of the follow API and cache tools by optimizing SQL queries, introducing caching mechanisms, and enhancing cache inspection tools.
Proposed Changes
- SQL Optimization:
- Replace
LEFT JOINwithINNER JOINinget_followersandget_followers_by_pageto improve performance by assuming data integrity (all follower IDs exist inhive_accounts). - Improve SQL query formatting and readability.
- Add comments to explain the optimization rationale.
- Replace
- Code Optimization in
bridge_api/methods.py:- Add result caching for
get_post(TTL: 180s) andget_account_posts(TTL: 30s). - Extract
_filter_hidden_postshelper function to eliminate code duplication. - Optimize hidden posts filtering logic using set operations to reduce time complexity from O(n²) to O(n).
- Unify start parameter handling logic for better maintainability.
- Add result caching for
- Cache Checker Tools Improvements:
- Support reading Redis URL from the
REDIS_URLenvironment variable incheck_cache.pyandcheck_cache_keys.py. - Update usage instructions to recommend using environment variables.
- Add
check_cache.py: Basic Redis cache validity check script. - Add
check_cache_keys.py: Detailed cache key inspection script with statistics. - Add
README.md: Comprehensive guide for cache troubleshooting and optimization.
- Support reading Redis URL from the
Upvoted! Thank you for supporting witness @jswit.