@@ -106,7 +106,6 @@ public function missing($key)
106
106
*
107
107
* @param array|string $key
108
108
* @param mixed $default
109
- * @return mixed
110
109
*/
111
110
public function get ($ key , $ default = null ): mixed
112
111
{
@@ -251,8 +250,6 @@ public function put($key, $value, $ttl = null)
251
250
252
251
/**
253
252
* {@inheritdoc}
254
- *
255
- * @return bool
256
253
*/
257
254
public function set ($ key , $ value , $ ttl = null ): bool
258
255
{
@@ -262,7 +259,6 @@ public function set($key, $value, $ttl = null): bool
262
259
/**
263
260
* Store multiple items in the cache for a given number of seconds.
264
261
*
265
- * @param array $values
266
262
* @param \DateTimeInterface|\DateInterval|int|null $ttl
267
263
* @return bool
268
264
*/
@@ -296,7 +292,6 @@ public function putMany(array $values, $ttl = null)
296
292
/**
297
293
* Store multiple items in the cache indefinitely.
298
294
*
299
- * @param array $values
300
295
* @return bool
301
296
*/
302
297
protected function putManyForever (array $ values )
@@ -526,6 +521,22 @@ public function flexible($key, $ttl, $callback, $lock = null, $alwaysDefer = fal
526
521
return $ value ;
527
522
}
528
523
524
+ /**
525
+ * Set the expiration of a cached item; null TTL will retain indefinitely.
526
+ */
527
+ public function touch (string $ key , \DateTimeInterface |\DateInterval |int |null $ ttl = null ): bool
528
+ {
529
+ $ value = $ this ->get ($ key );
530
+
531
+ if (is_null ($ value )) {
532
+ return false ;
533
+ }
534
+
535
+ return is_null ($ ttl )
536
+ ? $ this ->forever ($ key , $ value )
537
+ : $ this ->store ->touch ($ this ->itemKey ($ key ), $ this ->getSeconds ($ ttl ));
538
+ }
539
+
529
540
/**
530
541
* Remove an item from the cache.
531
542
*
@@ -547,8 +558,6 @@ public function forget($key)
547
558
548
559
/**
549
560
* {@inheritdoc}
550
- *
551
- * @return bool
552
561
*/
553
562
public function delete ($ key ): bool
554
563
{
@@ -557,8 +566,6 @@ public function delete($key): bool
557
566
558
567
/**
559
568
* {@inheritdoc}
560
- *
561
- * @return bool
562
569
*/
563
570
public function deleteMultiple ($ keys ): bool
564
571
{
@@ -575,8 +582,6 @@ public function deleteMultiple($keys): bool
575
582
576
583
/**
577
584
* {@inheritdoc}
578
- *
579
- * @return bool
580
585
*/
581
586
public function clear (): bool
582
587
{
@@ -738,7 +743,6 @@ public function getEventDispatcher()
738
743
/**
739
744
* Set the event dispatcher instance.
740
745
*
741
- * @param \Illuminate\Contracts\Events\Dispatcher $events
742
746
* @return void
743
747
*/
744
748
public function setEventDispatcher (Dispatcher $ events )
@@ -750,7 +754,6 @@ public function setEventDispatcher(Dispatcher $events)
750
754
* Determine if a cached value exists.
751
755
*
752
756
* @param string $key
753
- * @return bool
754
757
*/
755
758
public function offsetExists ($ key ): bool
756
759
{
@@ -761,7 +764,6 @@ public function offsetExists($key): bool
761
764
* Retrieve an item from the cache by key.
762
765
*
763
766
* @param string $key
764
- * @return mixed
765
767
*/
766
768
public function offsetGet ($ key ): mixed
767
769
{
@@ -773,7 +775,6 @@ public function offsetGet($key): mixed
773
775
*
774
776
* @param string $key
775
777
* @param mixed $value
776
- * @return void
777
778
*/
778
779
public function offsetSet ($ key , $ value ): void
779
780
{
@@ -784,7 +785,6 @@ public function offsetSet($key, $value): void
784
785
* Remove an item from the cache.
785
786
*
786
787
* @param string $key
787
- * @return void
788
788
*/
789
789
public function offsetUnset ($ key ): void
790
790
{
0 commit comments