Is there a simple way to locally store a JSON value with a TTL in a Firefox SDK add-on?
As far as I can tell, Firefox forces you to use their 'simple-storage' library. I can’t use a third-party library such as jStorage.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No,
simple-storageand DOM Storage are completely different things meaning that you cannot use a library like jStorage which is meant for work with DOM Storage.Then again, storing JSON and implementing TTL is simple enough to implement yourself. For JSON you use
JSON.parseandJSON.stringify. For TTL you simply store the TTL values somewhere and look them up when necessary. Something like this:I didn’t test this code but this should be pretty much all the code you need to implement this kind of feature.