CrispyWaffle
CrispyWaffle copied to clipboard
[FEATURE] Add async operations for `CacheManager` and `ICacheRepository` classes
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
-
Update
CacheManagerMethods:- Modify the
CacheManagerclass to include asynchronous versions of its methods. For example, addasyncandawaitto the existing methods for operations likeGet,Set, andRemove.
- Modify the
-
Implement Asynchronous Methods in Repositories:
- Update the following
ICacheRepositoryimplementations to support asynchronous operations:- CouchDBCacheRepository: Implement async methods for interacting with CouchDB.
- MemoryCacheRepository: Implement async methods for in-memory cache operations.
- RedisCacheRepository: Implement async methods for Redis interactions.
- Update the following
Tech Notes
-
Updating
CacheManager:- Identify all methods in
CacheManagerthat perform I/O operations or can benefit from async execution. - Modify these methods to be asynchronous by using
asyncandawait. For example:public async Task<T> GetAsync<T>(string key) { // Async logic here }
- Identify all methods in
-
Updating
ICacheRepositoryImplementations:-
CouchDBCacheRepository:- Update methods to use asynchronous CouchDB client operations.
- Example: Replace synchronous
client.Get()withawait 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
RedisCacheRepositoryare non-blocking.
- Utilize asynchronous Redis client methods, e.g.,
-
-
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.
Sorry, we have an error. Please try again.
Have feedback or need help? Feel free to email [email protected].