Is there a proper documentation or example for y-redis

I would like to use y-Redis. However, I have found nothing how to use it?

Hence, I was wondering whether you could provide me with some documentation or code example to get me started. :grinning:

Hi junioriosity
Did you have the code ?

I use a bit of what have been made here. So i think i understand how it is made.
Basically :

  • PersistenceDoc and RedisPersistence is the code that will be implemented by every β€˜client’.

  • PersistenceDoc add every update to Redis into a List, and publish the event to Redis via the pub/sub mechanism of Redis

  • PersistenceDoc reads update from Redis (from another client for example) when there is a publication on the channel.

  • Clock and Fetching clocks are here to avoid to add document updates that cames from Redis (via getUpdates β†’ applyUpdate to the document).

  • RedisPersistence manage the different Yjs room to handle multiple Y.Doc. And it unsubscribe from the pub/sub when a doc is closed.

@tdeverdiere Many thanks for getting back to me. I think this is very helpful. :slight_smile:

However, could you help me with some code snippets or something to use y-Redis for the following situation:

I would like to write a horizontally scalable y-js websocket backend.

When a new document is needed it is loaded from S3 into Redis or the backends unless already present. When users edit the texts and are subscribed to different websocket servers it is synced via Redis.

Every once in a while (say 1 minute) the current version of the document is persisted into S3. Also, if there are no subscribers anymore, it is persisted to S3 to free up resources in the backend and S3.

If you could help me with some code to make some progress in that direction, it would be terrific. :slight_smile:

There is this extended version of the y-websocket server: https://github.com/kapv89/yjs-scalable-ws-backend
It also implements a scalable architecture using Redis and a persistence layer (postgresql). You might be able to glean some insight from that.

1 Like