refactor: wire unified cache and invalidator in di
This commit is contained in:
@@ -2,6 +2,10 @@ import 'package:dio/dio.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../cache/cache_invalidator.dart';
|
||||
import '../cache/hybrid_cache_store.dart';
|
||||
import '../cache/memory_cache_store.dart';
|
||||
import '../cache/persistent_cache_store.dart';
|
||||
import '../api/api_client.dart';
|
||||
import '../api/i_api_client.dart';
|
||||
import '../storage/token_storage.dart';
|
||||
@@ -56,6 +60,19 @@ Future<void> configureDependencies() async {
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
sl.registerSingleton<SharedPreferences>(sharedPreferences);
|
||||
|
||||
final memoryCacheStore = MemoryCacheStore();
|
||||
final persistentCacheStore = PersistentCacheStore();
|
||||
final hybridCacheStore = HybridCacheStore(
|
||||
memory: memoryCacheStore,
|
||||
persistent: persistentCacheStore,
|
||||
);
|
||||
sl.registerSingleton<MemoryCacheStore>(memoryCacheStore);
|
||||
sl.registerSingleton<PersistentCacheStore>(persistentCacheStore);
|
||||
sl.registerSingleton<HybridCacheStore>(hybridCacheStore);
|
||||
sl.registerSingleton<CacheInvalidator>(
|
||||
CacheInvalidator(store: hybridCacheStore),
|
||||
);
|
||||
|
||||
final usersApi = UsersApi(apiClient);
|
||||
sl.registerSingleton<UsersApi>(usersApi);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user