You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs-src/in-memory.md
+29-16
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,25 @@
1
-
# in-memory
1
+
# InMemory Collections
2
2
3
-
When you do a heavy amount of operations on a `RxCollection`, you might want to optimize this by using the in-memory-replication of the collection. The in-memory-replication behaves equal to the original collection but is stored in the Ram of your computer.
3
+
When you do a heavy amount of operations on a `RxCollection`, you might want to optimize this by using the in-memory-replication of the collection. The in-memory-replication behaves equal to the original collection but is stored in the Memory of your computer instead of the hard drive
4
+
5
+
## Pros:
6
+
7
+
- Faster queries
8
+
- Faster writes
9
+
- Querying works over encrypted fields
10
+
11
+
## Cons:
12
+
13
+
- The original collection has to be small enough to fit into the memory
14
+
- No attachment-support
15
+
- Initial creation takes longer (all data is loaded from disc into the memory)
16
+
17
+
18
+
### encryption
19
+
Encrypted fields are automatically decrypted inside of the memory-collection. This means you can do queries over encrypted fields.
20
+
21
+
### replication
22
+
The memory-collection is two-way-replicated with its original collection. This means when you change documents on one of them, the update and the change-event will fire on both.
4
23
5
24
## RxCollection().inMemory();
6
25
@@ -20,24 +39,18 @@ const docs = await memCol.find().exec(); // has same result as on the original c
20
39
21
40
```
22
41
23
-
### encryption
24
-
Encrypted fields are automatically decrypted inside of the memory-collection. This means you can do queries over encrypted fields.
42
+
## RxCollection().awaitPersistence()
25
43
26
-
### replication
27
-
The memory-collection is two-way-replicated with its original collection. This means when you change documents on one of them, the update and the change-event will fire on both.
44
+
When you do a write into the inMemoryCollection, it takes some time until the change is replicated at the parents collections.
45
+
To know when you can be sure that all writes have been replicated, call `awaitPersistence()`
28
46
29
-
## Pros:
30
-
31
-
- Faster queries
32
-
- Faster writes
33
-
- Querying works over encrypted fields
34
-
35
-
## Cons:
47
+
```js
48
+
constmemCol=awaitmyCollection.inMemory();
36
49
37
-
- The original collection has to be small enough to fit into the memory
38
-
- No attachment-support
39
-
- Initial creation takes longer (all data is loaded from disc into the memory)
50
+
awaitmemCol.insert({foo:'bar'});
40
51
52
+
awaitmemCol.awaitPersistence(); // after this you can be sure that everything is replicated
Copy file name to clipboardexpand all lines: orga/releases/8.0.0.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -39,4 +39,4 @@ Because the fields of an `RxDocument` are defined dynamically by the schema and
39
39
Once per collection, a custom RxDocument-protoptype and constructor is created and each RxDocument of this collection is created with the constructor.
40
40
41
41
## Rewritten the inMemory-plugin
42
-
The inMemory-plugin was written with some wrong estimations. I rewrote it and added much more tests.
42
+
The inMemory-plugin was written with some wrong estimations. I rewrote it and added much more tests. Also `awaitPersistence()` can now be used to check if all writes have already been replicated into the parent collection.
0 commit comments