feat: add Redis caching for bounty listings (#128)#145
Open
TeapoyY wants to merge 1 commit intodevasignhq:mainfrom
Open
feat: add Redis caching for bounty listings (#128)#145TeapoyY wants to merge 1 commit intodevasignhq:mainfrom
TeapoyY wants to merge 1 commit intodevasignhq:mainfrom
Conversation
- Added ioredis dependency for Redis support - Created services/redis.ts with getCached, setCache, and deleteCachePattern helpers - Added Redis caching to GET /api/bounties listing endpoint with 30s TTL - Added cache invalidation on bounty update and complete actions - Cache key is deterministic based on query params for consistent hits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes issue #128: Redis caching for the bounty listings.
Added Redis caching to the
GET /api/bountiesendpoint to improve performance for frequently-accessed bounty listings.Changes
New dependency
ioredis^5.6.1 to@devasign/apipackageNew service:
packages/api/src/services/redis.tsgetRedisClient()- Lazy singleton Redis client usingREDIS_URLenv vargetCached<T>(key)- Get and parse JSON from Redis, returns null if Redis unavailablesetCache(key, value, ttlSeconds)- Set a JSON value with TTLdeleteCachePattern(pattern)- Scan and delete all keys matching a pattern (non-blocking)Cache implementation in
GET /api/bountiestech_stack,amount_min,amount_max,difficulty,status,limit)BOUNTY_LIST_CACHE_TTL)Cache invalidation
PATCH /api/bounties/:id- Invalidates allbounty:list:*keysPOST /api/bounties/:id/complete- Invalidates allbounty:list:*keysTesting
docker-compose up redisREDIS_URL=redis://localhost:6379in.envGET /api/bounties- first request hits DB, second request should be served from Redis cacheCloses #128