-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How would you persist the data in SQL Server? #80
Comments
This is tricky. The actual state is a binary representation, e.g. see our Mongo implementation: https://github.com/y-crdt/ydotnet/blob/main/YDotNet.Server.MongoDB/DocumentEntity.cs It is not readable and searchable. if you want that, you need another field and convert the document to JSON whenever you write it. There are a few methods for it: https://github.com/y-crdt/ydotnet/blob/main/YDotNet.Extensions/YDotNetExtensions.cs If you have a single server I would keep the document in memory and evict it when it is not used anymore. This is what we do in the server project: https://github.com/y-crdt/ydotnet/blob/main/YDotNet.Server/Internal/DocumentCache.cs If you have a workload with relatively few interactions (not a text editor), you can just load and store it for each request. Perhaps with optimistic concurrency and a few retries. |
@SebastianStehle any reason why both MongoDB and Redis have an expiration date then? If they are the final persistence layers, than shouldn't they be persisted forever? Or do you expect the client to save it somewhere else? Also, reading MongoDB implementation it seems like you are not really deleting the expired entities? Is the expiration stored there only as an example then? |
MongoDB is doing the deletion for you (https://github.com/y-crdt/ydotnet/blob/main/YDotNet.Server.MongoDB/MongoDocumentStorage.cs#L30). I have a use case, where the data is not stored forever, so I added it basically for myself. |
Just to get an idea, how should I approach the persisting of the document?
Right now, I am using Redis, which acts like a cache and persists the state in binary format for 5mins or so.
How should I approach persisting the data in a readable/searchable format in SQL Server?
The text was updated successfully, but these errors were encountered: