Skip to content

Implement Centralized Caching Service for CoinGecko Mock API#6

Open
Merango wants to merge 5 commits into
f5ee4aa2-87d6-43d4-a6ce-98204349da10from
feature-centralized-caching-service-1749229881
Open

Implement Centralized Caching Service for CoinGecko Mock API#6
Merango wants to merge 5 commits into
f5ee4aa2-87d6-43d4-a6ce-98204349da10from
feature-centralized-caching-service-1749229881

Conversation

@Merango
Copy link
Copy Markdown
Owner

@Merango Merango commented Jun 6, 2025

Implement Centralized Caching Service for CoinGecko Mock API

Description

Task

Create a centralized caching service

Acceptance Criteria

  • Centralized caching mechanism implemented
  • Singleton instance management works correctly
  • Type-safe cache operations are supported
  • Configurable cache settings are available
  • Error handling for invalid operations is robust
  • Performance monitoring capabilities are in place

Summary of Work

Overview

This pull request introduces a robust, centralized caching service for the CoinGecko Mock API, providing a flexible and type-safe caching mechanism using node-cache.

Key Changes

  • Implemented a singleton CacheService class in src/cache-service.ts
  • Provides comprehensive caching functionality with type safety
  • Supports configurable cache settings (TTL, check period)
  • Offers methods for cache manipulation and monitoring

Implementation Details

CacheService Features

  • Singleton pattern to ensure a single cache instance
  • Configurable default TTL (10 minutes) and check period (2 minutes)
  • Type-safe methods for setting, getting, and managing cache
  • Error handling for invalid cache operations
  • Ability to retrieve cache statistics

Supported Operations

  • set<T>(key, value, ttl?): Store values in cache
  • get<T>(key): Retrieve cached values
  • delete(key): Remove specific cache entries
  • has(key): Check cache key existence
  • clear(): Flush entire cache
  • getStats(): Retrieve cache performance metrics

Testing Approach

  • Comprehensive unit tests in src/cache-service.test.ts
  • Validate all cache operations
  • Test error scenarios and edge cases
  • Verify singleton behavior
  • Performance and reliability checks

Considerations

  • Default cache TTL is set to 10 minutes
  • Supports custom cache configuration
  • Easily extendable for future requirements

Next Steps

  • Integrate with existing route handlers
  • Add more comprehensive error logging
  • Consider distributed caching for production

Changes Made

  • Implemented singleton CacheService in src/cache-service.ts
  • Added type-safe cache methods
  • Configured default cache settings
  • Implemented error handling for cache operations
  • Created methods for cache manipulation and monitoring

Tests

  • Verify singleton instance creation
  • Test setting and getting cache values
  • Check cache key existence method
  • Validate error handling for invalid operations
  • Test cache clearing and deletion
  • Verify cache statistics retrieval

Signatures

Staking Key

84mPEB3qLaB2KQr1RXxNgYDF5DSv5ZyuDPpb9qeeNyyT: 44ZaEbCFGo2N5z6vJUBWPjSCFzyhNvBgeDmHomeoCATy3fg1XbBxL8Ur6jp6QoABaacgAjSUdR8M8MvyoqcRvWSKVc2hpwihjiyuv8dUCA1Rx29xdTaJnfYRvcNHSA6DUL3M9rkkBp4jb7SSJdG34hrChUtJ2sTDehVTUaL27Hnz4en1thkt7XybetJ8BH9qFb26mBD2Kq6STHZXFLCzHVRk1xSn6f14ZDBWL2yxhazSvJzz72fkvTHbmhU3hCXwEKrrVmbK7Zi1B4jEQBLG7TRX54iWbe8oxYbcqhXE7nFSpMCVXUpgt3kmiU5vTNPkufbNdHHtbU8LbeX3334B4XmQMymYa8EZLwpgCHcsm3GkMDpLSTxxWynyPzGhL9bkgHvPwmEtdg6bVZQKzFYKUfM57ZoaqA

Public Key

FLcUWedFSfvYeGjtnoXqgNtvtqEBCKwUK7Qn48hGnwsk: D9BUMBcpmsEq4fRb5gRkmECq2drP2RVVaCakpb2GUuqtATGfwodEnqhvKkVzg3xdo4uEMei5xfCiSeSw56yPS5SBhxFCM1Jb1TsULbtoJuWPu2mdGH1VgBMmFN5eJZSjr4da45xR8tfNCdGbwTEyusjNJnQ7uggKQKHJGJkJ4xXAvVxJDAuuYuXwEQzeFi4mNnEP35hPfs7WEufHWbAryYEhv7UwbqU7VsPhkoLKY2HssLKkybbAzindURcQ9ZRez7jn5KaZQr9z1A3MQhen11PKrLHne9MusPUhdn3RVdMQdascT44yXZaNJ6t4WMpj1sB6nwiDgjPLBz7SjvPDa3ifqVbihW7eJBHDK6pPbTTrQAC6A43Go69EzCzVxYrDnTrXnVDzhnwEhFhoRZN4gTRRRBj2rG

@Merango Merango changed the title [WIP] Feature: Implement Centralized Caching Service for CoinGecko Mock API Implement Centralized Caching Service for CoinGecko Mock API Jun 6, 2025
@Merango Merango marked this pull request as ready for review June 6, 2025 17:13
Alexdyn1927 added a commit to Alexdyn1927/Koii-Task-Funder-Express that referenced this pull request Jun 6, 2025
LearnHD added a commit to LearnHD/Koii-Task-Funder-Express that referenced this pull request Jun 6, 2025
Santix1234 added a commit to Santix1234/Koii-Task-Funder-Express that referenced this pull request Jun 6, 2025
tlxxxsracer added a commit to tlxxxsracer/Koii-Task-Funder-Express that referenced this pull request Jun 6, 2025
AlternateIf added a commit to AlternateIf/Koii-Task-Funder-Express that referenced this pull request Jun 7, 2025
Jockstrap6334 added a commit to Jockstrap6334/Koii-Task-Funder-Express that referenced this pull request Jun 7, 2025
xLDVx added a commit to xLDVx/Koii-Task-Funder-Express that referenced this pull request Jun 7, 2025
SoYan500 added a commit to SoYan500/Koii-Task-Funder-Express that referenced this pull request Jun 7, 2025
ranjhayhero added a commit to ranjhayhero/Koii-Task-Funder-Express that referenced this pull request Jun 7, 2025
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.

1 participant