angular-local-storage icon indicating copy to clipboard operation
angular-local-storage copied to clipboard

Adding control of expiration time in localstorage. Issue #133.

Open rodrigo-morais opened this issue 9 years ago • 10 comments

Hello,

I created a control to expiration time in localstorage.

For example: localStorageService.get('key', 300000); -> Verify if expiration time happened for 5 minutes in milliseconds.

Important, when need use localstorage against sessionstorage and must control expiration time.

Thanks.

rodrigo-morais avatar Oct 23 '14 00:10 rodrigo-morais

Coverage Status

Coverage decreased (-0.05%) when pulling e92355a69760502a06e3d01ac7984175e17f184a on rodrigo-morais:master into d85bdb5b24879ea956455647558df745baacf788 on grevory:master.

coveralls avatar Oct 23 '14 00:10 coveralls

Ah.. I got it. It's not a real expiration, the value still in the localStorage... mm.. I'm think we need the users feedback..

a8m avatar Oct 23 '14 06:10 a8m

If everyone think necessary, I can clear the key in localStorage.

I didn't that because in my use case was unnecessary and I not thought about.

rodrigo-morais avatar Oct 23 '14 10:10 rodrigo-morais

this is very useful! (y)

eshleebien avatar Oct 23 '14 16:10 eshleebien

Is this TTL support basically? if so, I rolled my own but would love to use the "built in" one.

brandonburkett avatar Oct 29 '14 14:10 brandonburkett

Would be awsome to have this.

brantje avatar Nov 01 '14 22:11 brantje

Hello,

I added for expiration data the option to remove key from localStorage. When method get is called with true in last/third parameter and expiration happen then the key will be remove from localStorage.

For example: localStorageService.get('key', 300000, true); -> Verify if expiration time happened for 5 minutes in milliseconds and if happens the key will be remove from localStorage.

The standard of remove flag is false. If not pass anything in parameter the key won't be remove.

Thanks.

rodrigo-morais avatar Nov 06 '14 00:11 rodrigo-morais

I need this.

Mouvedia avatar Feb 23 '15 11:02 Mouvedia

I want this feature.

raduq avatar Oct 26 '16 13:10 raduq

Is anyone interested in fixing up this PR? This seems to be very desired among users.

grevory avatar Jun 19 '17 17:06 grevory