Skip to content
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

persist in redis #2

Open
jfromaniello opened this issue Jan 28, 2013 · 3 comments
Open

persist in redis #2

jfromaniello opened this issue Jan 28, 2013 · 3 comments

Comments

@jfromaniello
Copy link

Hi, I am really interested in this project,

What would be the best way to store in redis? Should I store every operation ?

thanks

@timjb
Copy link
Member

timjb commented Jan 29, 2013

It really depends on your use case. If you want to be able to replay every single keystroke in the history of a document, you have to save every single operation. If you expect that clients get out of sync for a long time and want them to catch up and integrate the edits they did while they were offline, you have to store every operation. Otherwise, you can just wait until the users have paused editing (no new operations for a few seconds), merge all new operations and write them as a single operation to redis. In this case, redis is used only as a history, not as a store for operations that might be needed when a client sends an operation that has to be transformed against old operations.

There isn't a ready-made solution for saving the operations in redis from the JavaScript implementation. Since I don't have much time at the moment, you'll have to come up with a solution yourself.

But there is a lua script that runs in redis using the new scripting feature. It can be called with two keys (the key of the document and the key of the operations list), a revision number and optionally the a new operation (as a JSON string) and returns all operations since the given revision number (including the transformed new operation). It uses a linked list and does an LPUSH to save new operations on the list. I don't know whether you can use this script, or use it as a reference for implementing your own solution.

Kind Regards,
Tim

@jfromaniello
Copy link
Author

thank you very much! I will have a look and see how far I can get

@vote539
Copy link

vote539 commented May 13, 2017

FYI, I made a blog post with instructions on how to get OT in Redis up and running. Hope it helps!

https://blog.sffc.xyz/post/182052412225/operational-tranformation-in-redis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants