@@ -106,7 +106,6 @@ public function missing($key)
106106 *
107107 * @param array|string $key
108108 * @param mixed $default
109- * @return mixed
110109 */
111110 public function get ($ key , $ default = null ): mixed
112111 {
@@ -251,8 +250,6 @@ public function put($key, $value, $ttl = null)
251250
252251 /**
253252 * {@inheritdoc}
254- *
255- * @return bool
256253 */
257254 public function set ($ key , $ value , $ ttl = null ): bool
258255 {
@@ -262,7 +259,6 @@ public function set($key, $value, $ttl = null): bool
262259 /**
263260 * Store multiple items in the cache for a given number of seconds.
264261 *
265- * @param array $values
266262 * @param \DateTimeInterface|\DateInterval|int|null $ttl
267263 * @return bool
268264 */
@@ -296,7 +292,6 @@ public function putMany(array $values, $ttl = null)
296292 /**
297293 * Store multiple items in the cache indefinitely.
298294 *
299- * @param array $values
300295 * @return bool
301296 */
302297 protected function putManyForever (array $ values )
@@ -526,6 +521,22 @@ public function flexible($key, $ttl, $callback, $lock = null, $alwaysDefer = fal
526521 return $ value ;
527522 }
528523
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+
529540 /**
530541 * Remove an item from the cache.
531542 *
@@ -547,8 +558,6 @@ public function forget($key)
547558
548559 /**
549560 * {@inheritdoc}
550- *
551- * @return bool
552561 */
553562 public function delete ($ key ): bool
554563 {
@@ -557,8 +566,6 @@ public function delete($key): bool
557566
558567 /**
559568 * {@inheritdoc}
560- *
561- * @return bool
562569 */
563570 public function deleteMultiple ($ keys ): bool
564571 {
@@ -575,8 +582,6 @@ public function deleteMultiple($keys): bool
575582
576583 /**
577584 * {@inheritdoc}
578- *
579- * @return bool
580585 */
581586 public function clear (): bool
582587 {
@@ -738,7 +743,6 @@ public function getEventDispatcher()
738743 /**
739744 * Set the event dispatcher instance.
740745 *
741- * @param \Illuminate\Contracts\Events\Dispatcher $events
742746 * @return void
743747 */
744748 public function setEventDispatcher (Dispatcher $ events )
@@ -750,7 +754,6 @@ public function setEventDispatcher(Dispatcher $events)
750754 * Determine if a cached value exists.
751755 *
752756 * @param string $key
753- * @return bool
754757 */
755758 public function offsetExists ($ key ): bool
756759 {
@@ -761,7 +764,6 @@ public function offsetExists($key): bool
761764 * Retrieve an item from the cache by key.
762765 *
763766 * @param string $key
764- * @return mixed
765767 */
766768 public function offsetGet ($ key ): mixed
767769 {
@@ -773,7 +775,6 @@ public function offsetGet($key): mixed
773775 *
774776 * @param string $key
775777 * @param mixed $value
776- * @return void
777778 */
778779 public function offsetSet ($ key , $ value ): void
779780 {
@@ -784,7 +785,6 @@ public function offsetSet($key, $value): void
784785 * Remove an item from the cache.
785786 *
786787 * @param string $key
787- * @return void
788788 */
789789 public function offsetUnset ($ key ): void
790790 {
0 commit comments