-
Notifications
You must be signed in to change notification settings - Fork 8
Backend Development: Caching
On this page, we describe our strategy for reducing the load of the application and preventing unnecessary repeated API calls.
Caching plays a crucial role in optimising the performance and efficiency of our application, especially when dealing with frequent API calls (AWS, n.d.). In order to reduce the load on our servers and improve response times, we have implemented a simple caching system.
The primary purpose of caching in our application is to store frequently accessed data temporarily, allowing us to retrieve it quickly without having to recall APIs or database queries. By caching data locally, we can reduce the load on our servers and improve overall system performance.
Our cache system can be referred to here.
We have implemented a simple caching system using the CacheClient
class. This class provides methods for storing, retrieving, and managing cached data.
When an instance of the CacheClient
class is created, it initialises an empty cache dictionary.
The retrieve
method allows us to retrieve data from the cache using a specified key. If the data is found in the cache, it is returned; otherwise, it returns False
.
The update
method allows us to update the cache with a new key-value pair. This method is typically used to cache data retrieved from API calls.
The reset
method allows us to reset the cache by clearing all stored data. This can be useful for refreshing the cache or clearing outdated data.
The generate_key
method generates a cache key based on the type of data being cached and any additional arguments provided. This ensures that each piece of data is uniquely identified in the cache.
Our simple caching system effectively reduces the load on our servers by caching frequently accessed data locally. By storing data temporarily in memory, we can significantly improve response times and enhance the overall performance of our application.
Amazon Web Services. (n.d.). Caching Overview.