Skip to content

Commit

Permalink
refactor(cache): refactor Cache class (#809)
Browse files Browse the repository at this point in the history
* refactor(cache): remove deprecated Cache class

The Cache class has been removed as its functionality is now handled by the Repository class.
This change helps streamline the codebase and removes duplicate implementations.

* Rename

* Remove some cases

* Rename return type

* Add alias method

* Adds comments

* Refactor

* Updated docs

* Add comment

---------

Co-authored-by: Deeka Wong <[email protected]>
  • Loading branch information
huangdijia and huangdijia authored Dec 21, 2024
1 parent 40f5809 commit ba28a92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions en/components/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ composer require friendsofhyperf/cache
```php
namespace App\Controller;

use FriendsOfHyperf\Cache\CacheInterface;
use FriendsOfHyperf\Cache\Contract\Repository as CacheInterface;
use Hyperf\Di\Annotation\Inject;

class IndexController
Expand Down Expand Up @@ -47,7 +47,11 @@ Cache::remember($key, $ttl=60, function() {
use FriendsOfHyperf\Cache\Facade\Cache;
use FriendsOfHyperf\Cache\CacheManager;

Cache::driver('co')->remember($key, $ttl=60, function() {
Cache::store('co')->remember($key, $ttl=60, function() {
// return sth
});

di(CacheManager::class)->store('co')->remember($key, $ttl=60, function() {
// return sth
});
```
6 changes: 3 additions & 3 deletions zh_CN/components/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ composer require friendsofhyperf/cache
```php
namespace App\Controller;

use FriendsOfHyperf\Cache\CacheInterface;
use FriendsOfHyperf\Cache\Contract\Repository as CacheInterface;
use Hyperf\Di\Annotation\Inject;

class IndexController
Expand Down Expand Up @@ -51,11 +51,11 @@ Cache::remember($key, $ttl=60, function() {
use FriendsOfHyperf\Cache\Facade\Cache;
use FriendsOfHyperf\Cache\CacheManager;

Cache::driver('co')->remember($key, $ttl=60, function() {
Cache::store('co')->remember($key, $ttl=60, function() {
// return sth
});

CacheManager::get('co')->remember($key, $ttl=60, function() {
di(CacheManager::class)->store('co')->remember($key, $ttl=60, function() {
// return sth
});
```
Expand Down

0 comments on commit ba28a92

Please sign in to comment.