每位使用者的IndexedDb [英] IndexedDb per multiple users

查看:122
本文介绍了每位使用者的IndexedDb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对IndexedDb最佳做法,如何管理不同用户的数据有疑问.

I have a question about IndexedDb best practices, how to manage different users' data.

场景:我有一个包含系统数据的mysql数据库.当用户登录系统时,我将其数据从mysql同步到IndexedDb,然后Web应用程序使用直接存储在indexeddb中的数据.用户下次登录系统时,不需要完全同步,因为他的数据已经存储在本地.

Scenario: I have a mysql database containing system data. When user login to the system, I synchronize his data from mysql into IndexedDb and then web application uses data stored directly in indexeddb. When user login next time to the system, full synchronization is not needed because his data is already stored locally.

问题是用户注销,然后在同一台计算机上另一个用户登录系统,因为IndexedDb包含先前用户的数据.

Problem is when user logs out, and then on the same computer another user login into the system, because IndexedDb contains data for previous user.

是否有最佳实践来管理这种情况?因为现在我看到2个选项:

Is there any best practice for managing such scenario? Because for now I see 2 options:

  1. 在注销和登录操作中,始终清除indexeddb数据.缺点是在这种情况下,每次用户登录系统时,我都需要执行完全同步.
  2. 摆脱IndexedDb,因为它不应用于这种情况,并直接从mysql获取数据.
  3. ?? <-请也许您有个主意,如何避免每次用户登录时完全同步,并确保其他用户的数据不被读取.

谢谢

推荐答案

我采用的做法是不在同一台计算机上存储多个帐户.这是一种安全风险,它可能使某人可以查看未经其许可的帐户中的数据.相反,当我检测到用户注销后又有其他用户重新登录时,我将删除当前缓存的数据,然后再保存新用户的数据.如果某人退出并且同一用户重新登录,则我永远不会删除其数据.仅当用户更改时,它才会被删除.

The practice I employed was not to store multiple accounts on the same machine. That is a security risk that could allow someone to view the data from accounts that they don't have permission to. Instead, when I detect that a user signs out and then a different user signs back in, I delete the currently cached data before saving the data from the new user. If a person signs out and the same user signs back in, I never delete their data. It only gets deleted when users change.

这篇关于每位使用者的IndexedDb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆