Skip to content

Latest commit

 

History

History
44 lines (28 loc) · 992 Bytes

File metadata and controls

44 lines (28 loc) · 992 Bytes

LocalStorageCache

Contents

Description

Use localStorage to implement expired cache.

Use the two strategies of lazy deletion and scheduled deletion to clean up the expired cache.

Usage

Include the JavaScript script in your HTML markup:

<script src="js/lsc.js"></script>

In your application code, set the cache to localStorage by calling the lsc.set method with the key, value, and expiration time as parameters:

lsc.set('DemoKey', 'DemoValue', 5);

Get the cached value from localStorage by calling the lsc.get method with the key as the parameter:

var val = lsc.get('DemoKey');

Requirements

The LocalStorageCache script has zero dependencies.

License

The LocalStorageCache is released under the MIT license.