Skip to content

fix(#134): Add generic get/set methods to CacheService#136

Merged
DevanshuNEU merged 1 commit into
OpenCodeIntel:mainfrom
DevanshuNEU:fix/134-cache-get-set
Dec 26, 2025
Merged

fix(#134): Add generic get/set methods to CacheService#136
DevanshuNEU merged 1 commit into
OpenCodeIntel:mainfrom
DevanshuNEU:fix/134-cache-get-set

Conversation

@DevanshuNEU

Copy link
Copy Markdown
Collaborator

Bug Fix: #134 - CacheService missing get/set methods

Problem

POST /api/v1/playground/validate-repo returns 500 Internal Server Error:

AttributeError: 'CacheService' object has no attribute 'get'

The endpoint uses generic cache.get() and cache.set() but CacheService only had specialized methods like get_search_results().

Solution

Added generic methods to CacheService:

def get(self, key: str) -> Optional[Dict]:
    """Get value by key (generic cache access)."""
    
def set(self, key: str, value: Dict, ttl: int = 300) -> bool:
    """Set value by key with TTL (default 5 min)."""

Features

  • Graceful handling when Redis unavailable (returns None/False)
  • Proper error handling with logging
  • Metrics tracking (cache_hits, cache_misses, cache_errors)
  • Consistent with existing method patterns

Tests Added

8 new unit tests in test_cache_service.py:

  • test_get_returns_cached_value
  • test_get_returns_none_when_key_missing
  • test_get_returns_none_when_redis_unavailable
  • test_get_handles_redis_error
  • test_set_stores_value_with_ttl
  • test_set_uses_default_ttl
  • test_set_returns_false_when_redis_unavailable
  • test_set_handles_redis_error

Test Results

52 passed (44 anonymous indexing + 8 cache service)

Next Step

After merge, ping Arjun to flip USE_MOCK = false in frontend.

Fixes #134

- Add get(key) method for arbitrary key-value cache access
- Add set(key, value, ttl) method with 5min default TTL
- Both methods handle Redis unavailability gracefully
- Proper error handling and logging
- Add 8 unit tests for new methods

Fixes AttributeError in /playground/validate-repo endpoint.
@vercel

vercel Bot commented Dec 26, 2025

Copy link
Copy Markdown

@DevanshuNEU is attempting to deploy a commit to the Dev's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Dec 26, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
opencodeintel Ignored Ignored Preview Dec 26, 2025 8:55pm

@DevanshuNEU DevanshuNEU merged commit 3f10276 into OpenCodeIntel:main Dec 26, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: CacheService missing get/set methods breaks validate-repo endpoint

1 participant