php cache
5.1.0
PHP 8.1+에 대한 PSR/Simple-Cache 구현.
루트 디렉토리에서 Repo를 복제하고 composer install 실행할 수 있습니다. 다른 곳에 포함시키려는 경우 Composer.json 에 다음을 추가하십시오.
(참고 : dev-main 버전 제약 조건으로 교체하십시오 (예 : ^4.1 유효한 버전은 릴리스 참조)
{
"require" : {
"php" : " ^8.1 " ,
"chillerlan/php-cache" : " dev-main "
}
} 터미널을 통한 설치 : composer require chillerlan/php-cache
이익!
원하는 CacheInterface 로 캐시 인스턴스를 호출하기 만하면됩니다.
// Redis
$ redis = new Redis ;
$ redis -> pconnect ( ' 127.0.0.1 ' , 6379 );
$ cache = new RedisCache ( $ redis );
// Memcached
$ memcached = new Memcached ( ' myCacheInstance ' );
$ memcached -> addServer ( ' localhost ' , 11211 );
$ cache = new MemcachedCache ( $ memcached );
// APCU
$ cache = new APCUCache ;
// File
$ cache = new FileCache ( new CacheOptions ([ ' cacheFilestorage ' => __DIR__ . ' /../.cache ' ]));
// Session
$ cache = new SessionCache ( new CacheOptions ([ ' cacheSessionkey ' => ' _my_session_cache ' ]));
// Memory
$ cache = new MemoryCache ; PsrSimpleCacheCacheInterface 참조하십시오
$ cache -> get (string $ key , $ default = null ); // -> mixed
$ cache -> set (string $ key , $ value , int $ ttl = null ):bool
$ cache -> delete (string $ key ):bool
$ cache -> has (string $ key ):bool
$ cache ->clear():bool
$ cache -> getMultiple (array $ keys , $ default = null ):array // -> mixed[]
$ cache -> setMultiple (array $ values , int $ ttl = null ):bool
$ cache -> deleteMultiple (array $ keys ):bool나는 녹은 메모리 모듈, 부풀린 하드 디스크, 자체 유발 된 DOS, 깨진 화면 등에 대해 책임을지지 않습니다. 자신의 위험에 따라 사용하십시오! ?