我正在使用一个api,我从db获取数据,然后显示为json。数据很大并且每秒增加一次,我设法通过在第一次加载时将其保存在localStorage中来减轻负载,然后在下一次获取时加载最新数据,然后将其添加到localStorage中。我的问题是,它达到了数据的最大大小。有没有办法在php上做到这一点?
JS
if(index == 0){
localStorage.setItem("figureChart1-"+aid, JSON.stringify(data));
var arrseries1 = data['B5'];
var arrseries2 = data['B6'];
var datetime = data['datetime'];
} else {
var chart1Json = JSON.parse( localStorage.getItem( 'figureChart1-'+aid ) );
var obj = {};
obj['id'] = chart1Json['id'].concat(data['id']);
obj['datetime'] = chart1Json['datetime'].concat(data['datetime']);
obj['B5'] = chart1Json['B5'].concat(data['B5']);
obj['B6'] = chart1Json['B6'].concat(data['B6']);
localStorage.setItem("figureChart1-"+aid, JSON.stringify(obj));
var arrseries1 = obj['B5'];
var arrseries2 = obj['B6'];
var datetime = obj['datetime'];
}