Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions flutter_cache_manager/lib/src/cache_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ class CacheStore {
}
}

bool memoryCacheContainsKey(String key) {
return _memCache.containsKey(key);
}

Future<void> dispose() async {
final provider = await _cacheInfoRepository;
await provider.close();
Expand Down
17 changes: 17 additions & 0 deletions flutter_cache_manager/test/cache_store_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,23 @@ void main() {
await store.getFile(fileUrl);
expect(await store.getFileFromMemory(fileUrl), isNotNull);
});

test(
'Store.memoryCacheContainsKey should return true if the key is present in the memory cache',
() async {
var config = createTestConfig();
var store = CacheStore(config);

var cacheObject = CacheObject(
'baseflow.com/test.png',
relativePath: 'testimage.png',
validTill: clock.now().add(const Duration(days: 7)),
);
await store.putFile(cacheObject);

expect(store.memoryCacheContainsKey('baseflow.com/test.png'), true);
expect(store.memoryCacheContainsKey('unseen-file'), false);
});
});

group('Storing files in store', () {
Expand Down