guibranco / CrispyWaffle

🧰 🛠️ Crispy Waffle project - toolkit for .NET projects
https://guibranco.github.io/CrispyWaffle/
MIT License
23 stars 20 forks source link

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

Open guibranco opened 4 years ago

guibranco commented 4 years ago

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

gitauto-ai[bot] commented 1 month ago

Sorry, we have an error. Please try again.

Have feedback or need help? Feel free to email info@gitauto.ai.