如何在本地存储数据? [英] How to store data locally?

查看:161
本文介绍了如何在本地存储数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建网络分析工具来处理跟踪点击事件和鼠标移动,为此,我不想每次都将数据发送到服务器鼠标移动点击,而是我计划在本地保存并在会话超时或同时将数据发送到服务器关闭浏览器或选项卡(关闭网站)。



注意:大量数据要存储在本地。



我知道在本地存储数据的一些可能方法。

  1.LocalStorage: 
缺点:特定领域,所以我不能依靠这个。

2.Cookie
缺点:1.如果cookie被禁用,则分析失败
2.无法存储大量数据
(场景:每个鼠标移动
坐标应该被捕获)

我有两个问题:

1.在本地存储数据是否是好的做法(特别是使用网站分析)?bb b b b b是否存在其他可能的存储方式大数量(无法假设)数据在本地?

Safari和Chrome有一个Web SQL数据库API,因此您可以使用sqlite而不是原始本地存储。我发现了一篇很好的 有关sqlite用法的文章Web浏览器



另一种选择是将数据保存在内存中(并在特定大小时将其推送到服务器达到)。


I am building web analytics tools which deal with tracking the click events and mouse movements, For this, I don't want to send the data to the server for every mouse move or click, instead I planned to save locally and send the data to the server at session time out or while closing the browser or tab (closing the web site).

Note: Large amount of data is to be stored locally.

I know some possible ways to store the data locally.

 1.LocalStorage:
      Drawbacks:  Domain Specific so i can't rely on this.

 2.Cookie
     Drawbacks: 1.Analytics fails if cookie is disabled
                2.Not possible to store large amount of data
                     (scenario: Every mouse movement 
                      co-ordinates should be captured)

I have two questions:

1.Whether storing data locally is good practice (specifically with web analytics)?

2.Is there any other possible ways of storing large amount (cannot assume) of data locally?

解决方案

At least Safari and Chrome have a Web SQL Database API so you'll be able to use sqlite instead of raw local storage. I found a good article about sqlite usage in web browser.

An other option would be to keep your data straight in memory (and push it to the server when a certain size is reached).

这篇关于如何在本地存储数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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