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/docs/persistence/index.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@ title: Data Persistence
5
5
6
6
The `Build5Nines.SharpVector` library provides easy-to-use methods for saving a memory-based vector database to a file or stream and loading it again later. This is particularly useful for caching indexed content between runs, deploying pre-built vector stores, or shipping databases with your application.
7
7
8
+
---
9
+
8
10
## :material-file: File Persistence
9
11
10
12
`Build5Nines.SharpVector` supports persisting the vector database to a file.
@@ -51,6 +53,8 @@ vdb.LoadFromFile(filePath);
51
53
awaitvdb.LoadFromFileAsync(filePath);
52
54
```
53
55
56
+
---
57
+
54
58
## :material-file-move: Persist to Stream
55
59
56
60
The underlying methods used by `SaveToFile` and `LoadFromFile` methods for serializing the vector database to a `Stream` are available to use directly. This provides support for reading/writing to `MemoryStream` (or other streams) if the vector database needs to be persisted to something other than the local file system.
The `BasicDiskVectorDatabase` provides a basic vector database implementation that automatically stores the vector store and vocabulary store to disk. It's implmentation of vectorization is the same as the `BasicMemoryVectorDatabase`, but with the modification that it automatically persists the database to disk in the background to the specified folder path.
105
+
106
+
Here's a basic example of using `BasicDiskVectorDatabase`:
107
+
108
+
```csharp
109
+
// specify the folder where to persist the database data on disk
0 commit comments