Created
April 9, 2012 12:29
-
-
Save d0ugal/2343136 to your computer and use it in GitHub Desktop.
locache.js example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var seconds = 60 | |
locache.set("key", { | |
'user': 1, | |
'books': ['a', 'b', 'c'] | |
}, seconds) | |
locache.get("key") | |
// {'user': 1, 'books': ['a', 'b', 'c']} | |
// Note the object is returned, not a string. | |
// Now wait, 60 seconds. | |
locache.get("key") | |
// null | |
// If you want to store a value only | |
// for the users session, use the following | |
locache.session.set("private", { | |
'likes': ['kittens', 'JavaScript'] | |
}) | |
// All the other methods work for the | |
// session cache too | |
locache.session.get("private") | |
// All values stored on the session cache will | |
// expire when the user closes the browser. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment