Baseflow / flutter_cache_manager

Generic cache manager for flutter
https://baseflow.com
MIT License
739 stars 426 forks source link

Method in the CacheStore to know if a key is in the memory cache #355

Open vinicius0026 opened 2 years ago

vinicius0026 commented 2 years ago

🚀 Feature Requests

I need a way to synchronously know if a given key is present in the cache.

Contextualize the feature

In our app, we use the same image with different sizes (e.g., a small version for a listing page with a link and a large version on the details page). We want to show the smaller version of the image while the larger one is loading. The URLs for each size are different (as is the cache key).

I know that the actual file might be removed and the key will still be in the memory cache, but that's fine - this is a best-effort thing and doesn't need to be always accurate (although in our case it will very likely be in the cache bc we're reusing an image that was visible in the previous screen).

Describe the feature

Expose a method to check if a given key is in the memory cache.

Platforms affected (mark all that apply)

I have opened a PR (https://github.com/Baseflow/flutter_cache_manager/pull/354) adding a method to the cache_store.dart class.