-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Add Cache::touch()
& Store::touch()
for TTL Extension
#55954
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for submitting a PR! Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
52bc6b1
to
73fa810
Compare
Cache::touch()
& Store::touch()
for TTL Extension
This is pretty cool. One caveat though is the addition of the method to the cache repository contract which will be a breaking change to any existing implementations. For that reason we may probably need to target this to |
Cache::touch()
& Store::touch()
for TTL ExtensionCache::touch()
& Store::touch()
for TTL Extension
73fa810
to
485efd0
Compare
@taylorotwell Done. |
@@ -4,6 +4,7 @@ | ||
|
||
use Illuminate\Cache\ApcStore; | ||
use Illuminate\Cache\ApcWrapper; | ||
use Illuminate\Support\Carbon; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new import but not being added to the tests.
@@ -7,6 +7,7 @@ | ||
use Illuminate\Database\Connection; | ||
use Illuminate\Database\PostgresConnection; | ||
use Illuminate\Database\SQLiteConnection; | ||
use Illuminate\Support\Carbon; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new import but not being added to the tests.
This pull request introduces the
Cache::touch()
method, addressing a fundamental challenge that developers encounter frequently: extending cache TTL without the overhead of retrieving and re-storing data.Basic Usage:
Simplifies Common Patterns:
Cache:touch()
&$store->touch()
returntrue
on success andfalse
when the item is not found in the cache.Cache:touch()
accepts anint
,DateTimeInterface
, orDateInterval
for extending the TTL;null
will extend the TTL indefinitely;$store->touch()
requires anint
(conversion is handled in theRepository
.This pull request includes the following:
Cache
FacadeRepository
andStore
ContractsApcStore
,ArrayStore
,DatabaseStore
,DynamoDbStore
,FileStore
,MemcachedStore
,MemoizedStore
,NullStore
, andRedisStore
Primary Use Cases
1. Activity-Based Cache Extension
2. Cache Warming Maintenance
3. Progressive Cache Strategies
Real-World Scenarios
E-commerce Product Caching
API Response Caching
Performance Benefits
Network/Storage Efficiency
GET
+SET
operations, uses singleEXPIRE
commandSELECT
+UPDATE
, uses singleUPDATE
on timestampTOUCH
command instead ofGET
+SET
Memory Efficiency
Cache::touch($key, $seconds)
is immediately understandabletouch()
command developers know