How To provide a temporary database upon user login?


Hello.
Does anyone know how to provide a temporary database upon user login?

■ Premise
・ Developing a voice-based social networking service (SNS).
・ There exists a database of Voice including fields “title” “liked_count” etc.

■ Objective
・ Instead of referencing the master database, I want users to refer to a temporarily created copy of the database upon logging in.
・ User-initiated data changes should not be reflected immediately but upon page reload, updating the master database.

Specifically, the process entails:
i) Upon userX login, create copies of the current Voice as Voice_temp_userX_01 and Voice_temp_userX_01_forEdit.
ii) X accesses the site, referencing Voice_temp_userX_01. Changes (e.g., posting new voice, adding favorites) are saved to Voice_temp_userX_01_forEdit.
iii) When X reloads the page, changes from Voice_temp_userX_01_forEdit are reflected in Voice. Subsequently, create copies of the current Voice as Voice_temp_userX_02 and Voice_temp_userX_02_forEdit.
iv) Return to step ii.


The background of the question is as follows:

Site Mechanism:
・User-submitted voice is displayed in order of the number of favorites.
・Viewers can select from the list for playback. When playback ends, the next item plays automatically. (If it’s the last item, the player stops.)
・Repeating Group is used for listing, and Custom Audio Player is used for playback.

Issue Behavior:
・Audio A (1 favorite), Audio B (0), Audio C (0) are displayed in that order.
・While playing C, if C is favorited, the playback of C continues, but the order changes to C, A, B.
・When playback of C ends, it should either stop the player (reflecting the original order) or move on to playing A (reflecting the new order).
・However, due to the reordering during playback,
- on the listing: There are no audios playing (reflecting the original order).
- Yet, the player continues playing Audio A (reflecting the new order).

In addition to this, bugs can occur due to real-time database updates.
For example, if another user submits or favorites an audio while someone is listening, the list is reordered, resulting in a similar bug.