Navigation

Home
Search
Submit A Resource
Contact Us
About Functionn

Subscription Options


Subscribe By Email (265+)


Lists


Archives

Apr 10, 2012

Author: Hirvesh Posted At: 4/10/2012 Tags: , ,

Locache - JavaScript Caching Framework For Client Side In The Browser Using localStorage

Share:
Locache is a JavaScript caching framework for client side caching in the browser using localStorage. With a memcache inspired API usage is very easy and familiar.  Locache has no dependencies and is very small.

Locache gracefully degrades when the browser doesn't support localStorage. Usually this will be IE6 or IE7, you wont get any errors, but caching attempts will be silently dropped and lookups will always appear to be a cache miss.


Setting, Getting And Removing Values

Values can be stored one at a time as shown below, these values will never expire and will only be removed when you (or the browser) removes them.


When you store an object, that's what you'll get back. For example, a number:


Storing complex objects isn't a problem too. Just make sure they are JSON serializable.


You can also perform batch operations.


Setting Values That Expire



Incrementing And Decrementing? Sure.



Flushing The Cache

Use the following to clear only the locache values stored in localStorage.


Performing Cleanup

Since localStorage doesn't support expiring values, they will still be left around. This may or may not be a problem for you. If you want to make sure they are cleaned up, use the following method on page load, or with a setTimeout loop.


Requirements: None
Demohttps://github.com/d0ugal/locache
License: MIT License

Daily Posts, Be Updated, Subscribe:

Want Free Web Resources? Enter Your Email And We'll Send It To You - Daily! (265+ Subscribers)

Yup, it's that straight forward! Enter your email address below and we'll send you the latest web resources to your inbox, everyday. We don't do spam. Ever.

Trending Posts On Functionn This Week

Share:

Other Interesting Resources:

0 comments:

Post a Comment

 


Recent Posts

Popular Categories



Popular Components



Popular Licenses