Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.48 KB

File metadata and controls

41 lines (30 loc) · 1.48 KB

Summary of Changes

1. Added TODO Comment in Code

File: obp-api/src/main/scala/code/api/util/RateLimitingUtil.scala

Added a TODO comment at line 154 explaining the optimization opportunity:

  • Remove redundant EXISTS check since GET returns None for non-existent keys
  • This would reduce Redis operations from 2 to 1 (25% reduction per request)
  • Includes example of simplified code

Change: Only added comment lines, no formatting changes.

2. Documentation Created

File: REDIS_RATE_LIMITING_DOCUMENTATION.md

Comprehensive documentation covering:

  • Overview and architecture
  • Configuration parameters
  • Rate limiting mechanisms (authorized and anonymous)
  • Redis data structure (keys, values, TTL)
  • Implementation details of core functions
  • API response headers
  • Monitoring and debugging commands
  • Error handling
  • Performance considerations

Note: All Lua script references have been removed as requested.

3. Files Removed

  • REDIS_OPTIMIZATION_ANSWER.md - Deleted (contained Lua-based optimization suggestions)

Key Insight

Q: Can we just use INCR instead of SET, INCR, and EXISTS?

A: Partially, yes:

  • ✅ EXISTS is redundant - GET returns None when key doesn't exist (25% reduction)
  • ❌ Can't eliminate SETEX - INCR doesn't set TTL, and we need TTL for automatic counter reset
  • Current pattern (SETEX for first call, INCR for subsequent calls) is correct for the Jedis wrapper

The TODO comment marks where the EXISTS optimization should be implemented.