Skip to content

Instantly share code, notes, and snippets.

@d0ugal
Created April 9, 2012 12:29
Show Gist options
  • Save d0ugal/2343136 to your computer and use it in GitHub Desktop.
Save d0ugal/2343136 to your computer and use it in GitHub Desktop.
locache.js example.
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