📢 Performance Optimization: Redis Caching for `get_ranked_posts` API

in #steemitlast month

PR #353 has been merged (commit e3ce148c1c791138f1d0694e0e013e9c4d9e9a7f), introducing significant performance improvements to the get_ranked_posts endpoint.

What's New

The get_ranked_posts function now implements Redis-based caching to reduce database load and improve response times. Key enhancements include:

  • Smart caching strategy: Results are cached with TTL values tailored to each sort type:

    • created: 3 seconds
    • trending, hot, promoted: 300 seconds (5 minutes)
    • payout, payout_comments: 30 seconds
    • muted: 600 seconds (10 minutes)
  • Efficient cache key generation: Uses MD5 hashing to create compact cache keys from query parameters

  • Improved parameter validation: Enhanced input validation and normalization before query execution

This optimization significantly reduces database queries for frequently accessed post rankings while maintaining data freshness appropriate to each sort type.

Sort:  

Upvoted! Thank you for supporting witness @jswit.