friendsofhyperf / cache

[READ-ONLY]The cache component for Hyperf.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache

Latest Stable Version Total Downloads License

The cache component for Hyperf.

Installation

  • Installation
composer require friendsofhyperf/cache

Usage

  • Inject
namespace App\Controller;

use FriendsOfHyperf\Cache\CacheInterface;
use Hyperf\Di\Annotation\Inject;

class IndexController
{
   
    #[Inject]
    private CacheInterface $cache;

    public function index()
    {
        return $this->cache->remember($key, $ttl=60, function() {
            // return sth
        });
    }
}
  • Facade
use FriendsOfHyperf\Cache\Facade\Cache;

Cache::remember($key, $ttl=60, function() {
    // return sth
});
  • Switch driver
use FriendsOfHyperf\Cache\Facade\Cache;
use FriendsOfHyperf\Cache\CacheManager;

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

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

Methods

Likes Laravel-Cache

Contact

License

MIT

About

[READ-ONLY]The cache component for Hyperf.

License:MIT License


Languages

Language:PHP 100.0%