Closed elliotlings closed 6 years ago
Change the EXPIRY_UNITS. https://github.com/pamelafox/lscache/blob/master/lscache.js#L44
That is not possible if you import the module.
I also don't understand why it was necessary to count the expiration time in minutes.
I'm afraid I don't remember why I decided to do it as minutes. I probably had never had a use case where I needed to have an expiry of less than 1 minute. We can't change the expiry unit now, as that'd break the API, but someone could send a PR that has a method to reset the expiry units, or a PR that rewrites the internal code so that fractional times work. (*If possible)
+1 Actually, my primary interest is unit testing. If I have 5 tests, I'd REALLY like to be able to set expiration times in milliseconds.
I had written a bunch of the code to implement this, was looking to testing, and discovered this line in your existing tests:
lscache.set(expiredKey, 'blech', 1/60); // Expire after one second
~This 100% settled my needs. I had wondered why the "time" argument was classified as a {number} and not an {int}, this is why!~
~I did a bit of experimentation, and it looks to me like using "fractional minutes" works just fine.~~
The tests work because with a 1/60 expiration it actually expires instantaneously. It looks to me like fractional times do NOT work currently.
Does the expiry time have to be a whole minute and it can it be less than a minute?