Skip to content

Commit

Permalink
[9.x] Improves Cache facade types (#45467)
Browse files Browse the repository at this point in the history
* Add generic hints to Cache

* Improves cache type system

Co-authored-by: Anders Jenbo <anders@jenbo.dk>
  • Loading branch information
nunomaduro and AJenbo committed Dec 31, 2022
1 parent c7cc6e6 commit 856ad15
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions Cache/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ interface Repository extends CacheInterface
/**
* Retrieve an item from the cache and delete it.
*
* @param string $key
* @param mixed $default
* @return mixed
* @template TCacheValue
*
* @param array|string $key
* @param TCacheValue|(\Closure(): TCacheValue) $default
* @return (TCacheValue is null ? mixed : TCacheValue)
*/
public function pull($key, $default = null);

Expand Down Expand Up @@ -66,28 +68,34 @@ public function forever($key, $value);
/**
* Get an item from the cache, or execute the given Closure and store the result.
*
* @template TCacheValue
*
* @param string $key
* @param \DateTimeInterface|\DateInterval|int|null $ttl
* @param \Closure $callback
* @return mixed
* @param \Closure(): TCacheValue $callback
* @return TCacheValue
*/
public function remember($key, $ttl, Closure $callback);

/**
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @template TCacheValue
*
* @param string $key
* @param \Closure $callback
* @return mixed
* @param \Closure(): TCacheValue $callback
* @return TCacheValue
*/
public function sear($key, Closure $callback);

/**
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @template TCacheValue
*
* @param string $key
* @param \Closure $callback
* @return mixed
* @param \Closure(): TCacheValue $callback
* @return TCacheValue
*/
public function rememberForever($key, Closure $callback);

Expand Down

0 comments on commit 856ad15

Please sign in to comment.