Add support for using expirations of more than 30 days #153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Memcached the expiration times are specified in seconds as unsigned integer value. The expiration can take following values:
0
- never expireUp to 30 days
i.e. 60x60x24x30 = 2.592.000 secondsgreater than 30 days
is interpreted as Unix timestamp e.g. can be used to expire cache on specific date.In order to support expiration values of more than 30 days, the check is performed when obtaining configured expiration when cache client
set()
andtouch()
calls. If the given expiration in seconds is greater than 30 days, we add the expiration value to the current instant of UTC timezone (Unix timestamp). In case expiration is less than or equals to 30 days, we do not perform any recalculation and use the existing expiration for cache client'sset()
andtouch()
calls.In this way we can continue using the
memcached.cache.expiration
&memcached.cache.expiration-per-cache
configuration properties as time-to-live value i.e. cache entry expiration. This change will not introduce any breaking change (e.g. expiring cache on specific date), being we did not allow expiration values of more than 30 days.Resolves #152