diff --git a/flutter_cache_manager/lib/src/cache_manager.dart b/flutter_cache_manager/lib/src/cache_manager.dart index 3b094ff6..cae88db5 100644 --- a/flutter_cache_manager/lib/src/cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_manager.dart @@ -5,7 +5,6 @@ import 'package:file/file.dart'; import 'package:flutter/foundation.dart' show visibleForTesting; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_cache_manager/src/cache_store.dart'; -import 'package:flutter_cache_manager/src/storage/cache_object.dart'; import 'package:flutter_cache_manager/src/web/web_helper.dart'; import 'package:uuid/uuid.dart'; diff --git a/flutter_cache_manager/lib/src/cache_store.dart b/flutter_cache_manager/lib/src/cache_store.dart index 395e3eaf..c213b144 100644 --- a/flutter_cache_manager/lib/src/cache_store.dart +++ b/flutter_cache_manager/lib/src/cache_store.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; -import 'package:flutter_cache_manager/src/storage/cache_object.dart'; import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart'; ///Flutter Cache Manager @@ -188,6 +187,10 @@ class CacheStore { } } + bool memoryCacheContainsKey(String key) { + return _memCache.containsKey(key); + } + Future dispose() async { final provider = await _cacheInfoRepository; await provider.close(); diff --git a/flutter_cache_manager/lib/src/web/web_helper.dart b/flutter_cache_manager/lib/src/web/web_helper.dart index 1b7e53a5..81b0e710 100644 --- a/flutter_cache_manager/lib/src/web/web_helper.dart +++ b/flutter_cache_manager/lib/src/web/web_helper.dart @@ -6,7 +6,6 @@ import 'package:clock/clock.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_cache_manager/src/cache_store.dart'; -import 'package:flutter_cache_manager/src/storage/cache_object.dart'; import 'package:flutter_cache_manager/src/web/queue_item.dart'; import 'package:rxdart/rxdart.dart'; import 'package:uuid/uuid.dart'; diff --git a/flutter_cache_manager/test/cache_manager_test.dart b/flutter_cache_manager/test/cache_manager_test.dart index 85f5f50b..a5f443f0 100644 --- a/flutter_cache_manager/test/cache_manager_test.dart +++ b/flutter_cache_manager/test/cache_manager_test.dart @@ -5,7 +5,6 @@ import 'package:clock/clock.dart'; import 'package:file/memory.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_cache_manager/src/cache_store.dart'; -import 'package:flutter_cache_manager/src/storage/cache_object.dart'; import 'package:flutter_cache_manager/src/web/web_helper.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; diff --git a/flutter_cache_manager/test/cache_store_test.dart b/flutter_cache_manager/test/cache_store_test.dart index 93a8bd7b..b440164c 100644 --- a/flutter_cache_manager/test/cache_store_test.dart +++ b/flutter_cache_manager/test/cache_store_test.dart @@ -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', () { diff --git a/flutter_cache_manager/test/helpers/json_repo_helpers.dart b/flutter_cache_manager/test/helpers/json_repo_helpers.dart index cf3494c6..c275c0e9 100644 --- a/flutter_cache_manager/test/helpers/json_repo_helpers.dart +++ b/flutter_cache_manager/test/helpers/json_repo_helpers.dart @@ -4,7 +4,6 @@ import 'package:clock/clock.dart'; import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; -import 'package:flutter_cache_manager/src/storage/cache_object.dart'; const String databaseName = 'test'; const String path = diff --git a/flutter_cache_manager/test/repositories/migration_test.dart b/flutter_cache_manager/test/repositories/migration_test.dart index 44124637..a4330775 100644 --- a/flutter_cache_manager/test/repositories/migration_test.dart +++ b/flutter_cache_manager/test/repositories/migration_test.dart @@ -1,6 +1,5 @@ import 'package:collection/collection.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; -import 'package:flutter_cache_manager/src/storage/cache_object.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; diff --git a/flutter_cache_manager/test/web_helper_test.dart b/flutter_cache_manager/test/web_helper_test.dart index 45bb777d..661ac5ea 100644 --- a/flutter_cache_manager/test/web_helper_test.dart +++ b/flutter_cache_manager/test/web_helper_test.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:clock/clock.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_cache_manager/src/cache_store.dart'; -import 'package:flutter_cache_manager/src/storage/cache_object.dart'; import 'package:flutter_cache_manager/src/web/web_helper.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart';