Skip to content
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

Add support for using expirations of more than 30 days #153

Merged

Conversation

igorbolic
Copy link
Member

@igorbolic igorbolic commented Mar 27, 2023

In Memcached the expiration times are specified in seconds as unsigned integer value. The expiration can take following values:

  1. 0 - never expire
  2. Up to 30 days i.e. 60x60x24x30 = 2.592.000 seconds
  3. Any value greater 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() and touch() 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's set() and touch() 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

@igorbolic igorbolic requested review from sasabolic and removed request for sasabolic March 27, 2023 08:20
@igorbolic igorbolic force-pushed the more-than-30-days-expiration branch from bded147 to dd8529a Compare March 28, 2023 04:42
In Memcached the expiration times are specified in seconds
as unsigned integer value. The expiration can take following
values:

1) `0` - never expire
2) `Up to 30 days` i.e. 60x60x24x30 = 2.592.000 seconds
3) Any value `greater 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()` and `touch()` 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's `set()` and `touch()` 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 sixhours-team#152
@igorbolic igorbolic force-pushed the more-than-30-days-expiration branch from dd8529a to c6f9fa6 Compare March 28, 2023 05:00
@igorbolic igorbolic requested a review from sasabolic March 28, 2023 05:46
Copy link
Member

@sasabolic sasabolic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx @igorbolic this is perfect!

@sasabolic sasabolic merged commit aada296 into sixhours-team:master Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to cache longer than 30 days
2 participants