Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache not deleted after stalePeriod is passed #947

Open
aggeloskoutanis opened this issue May 20, 2024 · 0 comments
Open

Cache not deleted after stalePeriod is passed #947

aggeloskoutanis opened this issue May 20, 2024 · 0 comments

Comments

@aggeloskoutanis
Copy link

🐛 Bug Report

I am implementing a CustomCachemanager with a stalePeriod of 1 minute to check if the cached data are deleted after the stale period passes. So far, it doesn't work and I don't know why. Any suggestion is welcome.

Expected behavior

The cached data are deleted after 1 minute.

Reproduction steps

  1. Created a CustomCacheManager

import 'package:flutter_cache_manager/flutter_cache_manager.dart';

class CustomCacheManager extends CacheManager with ImageCacheManager {
  factory CustomCacheManager() {
    return _instance;
  }

  CustomCacheManager._()
      : super(Config(key, stalePeriod: const Duration(minutes: 1)));
  static const key = 'libCachedImageData';

  static final CustomCacheManager _instance = CustomCacheManager._();
}
  1. Passed it in the CachedNetworkImage Constructor.
   CachedNetworkImage(
      imageUrl: imageUrl,
      fit: BoxFit.cover,
      cacheManager: CustomCacheManager(),
    );
  1. Ran the app, the image is loaded from the network as it should.
  2. Terminate the app.
  3. re-ran the app and the image is loaded from the cache as it should
  4. Terminate the app and wait for some time (i.e.: 10 mins)
  5. Launch the app. At this point, I expect the image to be fetched from the network again since the cache should be deleted. Instead, the image is still fetched from the cache.

I used the flag CachedNetworkImage.logLevel = CacheManagerLogLevel.verbose;

Am I missing something here?

Configuration

Version: 3.3.1

Platform:

  • Android 14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant