CrispyWaffle icon indicating copy to clipboard operation
CrispyWaffle copied to clipboard

[FEATURE] Add async operations for `CacheManager` and `ICacheRepository` classes

Open guibranco opened this issue 5 years ago • 4 comments

Description

Enhance the CacheManager class and its implementations to support asynchronous operations. This update will improve the performance and scalability of cache operations by allowing non-blocking interactions with the cache.

Tasks

  1. Update CacheManager Methods:

    • Modify the CacheManager class to include asynchronous versions of its methods. For example, add async and await to the existing methods for operations like Get, Set, and Remove.
  2. Implement Asynchronous Methods in Repositories:

    • Update the following ICacheRepository implementations to support asynchronous operations:

Tech Notes

  1. Updating CacheManager:

    • Identify all methods in CacheManager that perform I/O operations or can benefit from async execution.
    • Modify these methods to be asynchronous by using async and await. For example:
      public async Task<T> GetAsync<T>(string key)
      {
          // Async logic here
      }
      
  2. Updating ICacheRepository Implementations:

    • CouchDBCacheRepository:

      • Update methods to use asynchronous CouchDB client operations.
      • Example: Replace synchronous client.Get() with await client.GetAsync().
    • MemoryCacheRepository:

      • Although in-memory operations are typically fast, updating to async will help maintain consistency across the application.
      • Example: Wrap existing methods with Task.Run() for async behavior if needed.
    • RedisCacheRepository:

      • Utilize asynchronous Redis client methods, e.g., IDatabase.StringGetAsync(), IDatabase.StringSetAsync().
      • Ensure that all Redis operations in RedisCacheRepository are non-blocking.
  3. Testing:

    • Update or create unit tests to verify the correctness and performance of asynchronous methods.
    • Ensure tests cover various scenarios, including handling of exceptions and timeouts.

Additional Notes

  • Ensure that the new asynchronous methods are properly documented.
  • Review code for potential performance impacts and make optimizations as needed.
  • Collaborate with the team to identify and address any existing issues related to synchronous operations before applying async changes.

guibranco avatar Sep 07 '20 02:09 guibranco

Sorry, we have an error. Please try again.

Have feedback or need help? Feel free to email [email protected].

gitauto-ai[bot] avatar Sep 23 '24 00:09 gitauto-ai[bot]