Search in sources :

Example 1 with LocalSerializer

use of com.google.firebase.firestore.local.LocalSerializer in project firebase-android-sdk by firebase.

the class MemorySpecTest method initializeComponentProvider.

@Override
protected MemoryComponentProvider initializeComponentProvider(ComponentProvider.Configuration configuration, boolean garbageCollectionEnabled) {
    MemoryComponentProvider provider = new MemoryComponentProvider() {

        @Override
        protected Persistence createPersistence(Configuration configuration) {
            if (garbageCollectionEnabled) {
                return MemoryPersistence.createEagerGcMemoryPersistence();
            } else {
                DatabaseId databaseId = DatabaseId.forProject("projectId");
                LocalSerializer serializer = new LocalSerializer(new RemoteSerializer(databaseId));
                return MemoryPersistence.createLruGcMemoryPersistence(LruGarbageCollector.Params.Default(), serializer);
            }
        }
    };
    provider.initialize(configuration);
    return provider;
}
Also used : RemoteSerializer(com.google.firebase.firestore.remote.RemoteSerializer) MemoryComponentProvider(com.google.firebase.firestore.core.MemoryComponentProvider) DatabaseId(com.google.firebase.firestore.model.DatabaseId) LocalSerializer(com.google.firebase.firestore.local.LocalSerializer)

Example 2 with LocalSerializer

use of com.google.firebase.firestore.local.LocalSerializer in project firebase-android-sdk by firebase.

the class SQLiteComponentProvider method createPersistence.

@Override
protected Persistence createPersistence(Configuration configuration) {
    LocalSerializer serializer = new LocalSerializer(new RemoteSerializer(configuration.getDatabaseInfo().getDatabaseId()));
    LruGarbageCollector.Params params = LruGarbageCollector.Params.WithCacheSizeBytes(configuration.getSettings().getCacheSizeBytes());
    return new SQLitePersistence(configuration.getContext(), configuration.getDatabaseInfo().getPersistenceKey(), configuration.getDatabaseInfo().getDatabaseId(), serializer, params);
}
Also used : LruGarbageCollector(com.google.firebase.firestore.local.LruGarbageCollector) RemoteSerializer(com.google.firebase.firestore.remote.RemoteSerializer) SQLitePersistence(com.google.firebase.firestore.local.SQLitePersistence) LocalSerializer(com.google.firebase.firestore.local.LocalSerializer)

Aggregations

LocalSerializer (com.google.firebase.firestore.local.LocalSerializer)2 RemoteSerializer (com.google.firebase.firestore.remote.RemoteSerializer)2 MemoryComponentProvider (com.google.firebase.firestore.core.MemoryComponentProvider)1 LruGarbageCollector (com.google.firebase.firestore.local.LruGarbageCollector)1 SQLitePersistence (com.google.firebase.firestore.local.SQLitePersistence)1 DatabaseId (com.google.firebase.firestore.model.DatabaseId)1