clearCaching method
Clears the cache for the data retrieval operation.
When called, this method configures the current CoffeeRequestGet<T>
instance to not use the cache storage and clears the specified cache entry.
This is useful for ensuring that the most current data is retrieved from the
network, particularly when the cached data is outdated or no longer relevant.
The method accepts an optional key
parameter, which serves as a unique
identifier for the cache entry to be cleared.
Returns a CoffeeRequestGet<T> with caching disabled and the specified cache entry cleared.
Usage Examples
Clearing the cache for all entries:
var request = CoffeeRequestGet<CoffeeShop>()
.whereIs('isValid', true)
.clearCaching();
Clearing the cache with a custom key:
var request = CoffeeRequestGet<CoffeeShop>()
.whereIs('isOpen', true)
.clearCaching(key: 'openCoffeeShops');
Functional approach with cache clearing:
var request = CoffeeRequestGet<CoffeeShop>()
.whereIs((CoffeeShop shop) => shop.isValid, false)
.clearCaching();
Implementation
CoffeeRequestGet<T> clearCaching({ String key = '' }) {
_useCache = false;
_clearCache = true;
_cacheKey = key;
return this;
}