-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionally use sessionStorage #34
Comments
Just submitted a pull-request that "should" do this :) |
Don't see this in the main code. was hoping this lib did sessionStorage too. |
I don't know if it should be an extra param like "time" or "ttl". lscache.set('mykey1', 'myvalue1', 10); //mykey1 is dirty and can be deleted in 10 minutes
lscache.set('mykey2', 'myvalue2', 0, true); //mykey2 is dirty and can be deleted when user closes the browser
lscache.set('mykey3', 'myvalue3', 10, true); //mykey3 is dirty and can be deleted when user closes the browser or in 10 minutes Or/and lscache factory should have both storages like window lscache.local.set('mykey4', 'myvalue4', 10);
lscache.session.set('mykey5', 'myvalue5', 10); (function (root, factory) {
//...
}(this, function () {
var Cache = function(driver) {
this.driver = driver;
};
Cache.prototype = {
isSupported: function() {
if (this.driver === undefined) return false;
//test set
},
set: function(name, value, ttl) {
//...
this.driver.setItem(name, value);
//...
}
get: function(name){},
del: function(){}
};
var lscache = {
//legacy mode?
set: function(name, value, ttl, session) {
if (session) this.session.set(name, value, ttl);
else this.local.set(name, value, ttl);
}
};
lscache.session = new Cache(this.sessionStorage); //window.sessionStorage
lscache.local = new Cache(this.localStorage); //window.localStorage
//...
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: