HiveCePersister class

Hive CE-based persister for production use.

Uses Hive CE - the actively maintained community edition of Hive for fast, encrypted local storage.

Basic Usage:

import 'package:fluquery/fluquery.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Create and initialize the persister
  final persister = HiveCePersister();
  await persister.init();

  // Create QueryClient with persister
  final queryClient = QueryClient(persister: persister);

  // Restore cached data
  await queryClient.hydrate();

  runApp(
    QueryClientProvider(
      client: queryClient,
      child: MyApp(),
    ),
  );
}

Custom Box Name:

final persister = HiveCePersister(boxName: 'my_app_cache');

With Encryption:

final encryptionKey = Hive.generateSecureKey();
final persister = HiveCePersister(
  boxName: 'secure_cache',
  encryptionCipher: HiveAesCipher(encryptionKey),
);
Implemented types

Constructors

HiveCePersister({String boxName = 'fluquery_cache', HiveCipher? encryptionCipher, String? path})
Creates a new Hive CE persister.

Properties

boxName String
The name of the Hive box to use for storage
final
encryptionCipher → HiveCipher?
Optional encryption cipher for secure storage
final
hashCode int
The hash code for this object.
no setterinherited
isInitialized bool
Whether the persister is initialized
no setter
length int
Get the number of cached entries
no setter
path String?
Optional custom path for storage (defaults to app documents directory)
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() Future<void>
override
close() Future<void>
override
compact() Future<void>
Compact the Hive box to reduce file size
init() Future<void>
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
persistQuery(PersistedQuery query) Future<void>
override
removeQueries(bool filter(PersistedQuery)) Future<void>
override
removeQuery(String queryHash) Future<void>
override
restoreAll() Future<List<PersistedQuery>>
override
restoreQuery(String queryHash) Future<PersistedQuery?>
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited