缓存配置表(Caching configuration table)
我有配置应该缓存的表。 我只在应用程序启动时加载该表一次所有数据都不会被修改并且将被用于只读所以问题我是否需要一些缓存,如Ehcache或一些静态Map就足够了?
I have table with configurations which should be cached. I load that table only once on app start All data will not be modified and will be used read only So question do I need some cache like Ehcache or some static Map will be enough?
原文:https://stackoverflow.com/questions/18889331
最满意答案
您可以使用localStorage ,您可以在页面上添加项目并将它们加载到第二页上。
localStorage.setItem("global_array", JSON.stringify(global_array)); localStorage.setItem("pushIntoArray", pushIntoArray + "");
在另一页你可以做到这一点:
window["global_array"] = eval("(" + localStorage.getItem("global_array") + ")"); window["pushIntoArray"] = eval(localStorage.getItem("pushIntoArray"));
但是,您需要加载第一页,以确保您的设置存在于第二页中。
You can use localStorage where you can add items on a page and load them on the second page.
localStorage.setItem("global_array", JSON.stringify(global_array)); localStorage.setItem("pushIntoArray", pushIntoArray + "");
On the other page you can do this:
window["global_array"] = eval("(" + localStorage.getItem("global_array") + ")"); window["pushIntoArray"] = eval(localStorage.getItem("pushIntoArray"));
However, you will need to load the first page to make sure your settings exist in the second page.
相关问答
更多-
电脑二级考试 是考access 还是VPF[2022-06-08]
access -
在这种情况下,使用querySelectorAll更方便: var images = document.querySelectorAll('#gall figure img'); In this case it's more convenient to use querySelectorAll: var images = document.querySelectorAll('#gall figure img');
-
将值存储在localstorage中并从那里引用它。 function first() { localStorage.setItem('myItem', "something you want to store"); } function second() { myValue = null; if (localStorage.getItem('myItem')) { myValue = localStorage.getItem('myItem'); } } ...
-
是和否 - 你可以像这样创建一个对象 : var theObject = { one: "value 1", two: "value 2" }; 但它不是一个数组。 JavaScript中的真数组具有严格的数字索引。 (您可以将字符串命名的属性添加到JavaScript数组对象中,但它们不在数组的.length中。) 编辑 - 为对象(或任何对象)添加属性,可以使用. 或[]运营商: theObject.newProperty = "something new"; theObject[ computeN ...
-
你可以使用querySelector API。 这应该工作: thisRow.querySelector('#myId'); 如果你的元素id在整个文档中是唯一的(他们应该是这样),你可以只做document.getElementById 。 You could use querySelector API. This should work: thisRow.querySelector('#myId'); And if your element ids are unique across the doc ...
-
您几乎已经拥有了它,只需将您在发布的Javascript中所做的操作复制到第二页的上下文中即可: var storedValue = localStorage.getItem("param"); alert(storedValue); 虽然用点符号代替它会更好一些: const storedValue = localStorage.param; alert(storedValue); Page 1 Javascript: const global = "parameter"; localStorage. ...
-
JavaScript从不同的html页面访问相同的数组[复制](JavaScript access the same array from different html pages [duplicate])[2023-03-17]
您可以使用localStorage ,您可以在页面上添加项目并将它们加载到第二页上。 localStorage.setItem("global_array", JSON.stringify(global_array)); localStorage.setItem("pushIntoArray", pushIntoArray + ""); 在另一页你可以做到这一点: window["global_array"] = eval("(" + localStorage.getItem("global_array" ... -
问题在于 myFormData.splice(deleteValue); splice()需要一个起始索引,你传递一个字符串值。 请参阅如何从JavaScript中的数组中删除特定的元素? 关于如何使用它。 在你的情况下,它会 // get the index of the value in the array or -1 if it does not exist var index = myFormData.indexOf(deleteValue); // only try removing it, i ...
-
就像Sir McPotato建议您可以使用Local Store来实现这一点: // Store localStorage.setItem("Name", "What is your name"); // Retrieve document.getElementById("userName").innerHTML = localStorage.getItem("Name"); Like Sir McPotato suggested you could use Local Store to achieve ...
-
为什么需要配置MvcConfiguration? 如果你没有在类路径上使用百里香叶/自由标记/ vaadin它不会只是默认服务.html吗? 如果你在ur pom.xml中有thymeleaf,那么只需要它并尝试使用请求映射返回登录而不定义MVC配置并查看是否有效。 或者,使用freemarker,而不是thymeleaf cos thymeleaf在我看来有点可怕,并将文件保存为login.ftl,内容可以只是纯HTML。 无需定义MVC配置即可完美运行。 i found out that i can s ...