php cache
5.1.0
تنفيذ PSR/Simple Cache لـ PHP 8.1+.
يمكنك ببساطة استنساخ REPO وتشغيل composer install في دليل الجذر. في حال كنت ترغب في تضمينه في مكان آخر ، فقط أضف ما يلي إلى الملحن الخاص بك. 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 الناتجة عن نفسها ، والشاشات المكسورة وما إلى ذلك. ؟