-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
93 lines (93 loc) · 2.63 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<!--
/*
* LocalStorageCache Demo
* http://heihaozi.github.io/LocalStorageCache/
*
* Copyright 2020, heihaozi
* https://github.com/heihaozi/
*
* Licensed under the MIT license:
* https://opensource.org/licenses/MIT
*/
-->
<html lang="en">
<head>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<![endif]-->
<meta charset="utf-8"/>
<title>LocalStorageCache Demo</title>
<meta name="description" content="Use localStorage to implement expired cache. Use the two strategies of lazy deletion and scheduled deletion to clean up the expired cache."/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="css/demo.css"/>
<script type="text/javascript" src="js/lsc.js"></script>
</head>
<body>
<h1>LocalStorageCache Demo</h1>
<p>
Use localStorage to implement expired cache.
</p>
<p>
Use the two strategies of lazy deletion and scheduled deletion to clean up the expired cache.
</p>
<ul id="navigation">
<li>
<a href="https://github.com/heihaozi/LocalStorageCache/">Download</a>
</li>
<li>
<a href="https://github.com/heihaozi/LocalStorageCache/">Source Code</a>
</li>
<li>
<a href="https://github.com/heihaozi/LocalStorageCache/blob/master/README.md">Documentation</a>
</li>
<li><a href="https://github.com/heihaozi/">© heihaozi</a></li>
</ul>
<div>
<p>
<label for="setKey">Key:</label>
<input id="setKey" value="DemoKey"/>
</p>
<p>
<label for="setValue">Value:</label>
<input id="setValue" value="DemoValue"/>
</p>
<p>
<label for="setExpires">Expires:</label>
<input id="setExpires" value="5"/>
</p>
<p>
<button id="set" type="button">
Set
</button>
</p>
<p>
<hr/>
</p>
<p>
<label for="getKey">Key:</label>
<input id="getKey" value="DemoKey"/>
</p>
<p>
<button id="get" type="button">
Get
</button>
</p>
</div>
<script type="text/javascript">
document.getElementById('set').onclick = function (e) {
var key = document.getElementById('setKey').value;
var val = document.getElementById('setValue').value;
var expires = document.getElementById('setExpires').value;
lsc.set(key, val, expires);
alert('Set successfully!');
return false;
};
document.getElementById('get').onclick = function (e) {
var key = document.getElementById('getKey').value;
alert('The value is ' + lsc.get(key));
return false;
};
</script>
</body>
</html>