Skip to content

Use the two strategies of lazy deletion and scheduled deletion to implement expireable localStorage cache.

License

Notifications You must be signed in to change notification settings

heihaozi/LocalStorageCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Use the two strategies of lazy deletion and scheduled deletion to implement expireable localStorage cache.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published