尊龙凯时人生就是博

laravelÔõôʹÓûº´æ

laravelÊÇÒ»¸öÊ¢ÐеÄphp¿ò¼Ü £¬ËüÌṩÁ˸»ºñµÄ¹¦Ð§ºÍ¹¤¾ßÀ´×ÊÖúÎÒÃǸüÇáËɵع¹½¨¸ßЧµÄwebÓ¦ÓóÌÐò¡£ÆäÖÐÒ»¸öºÜÊÇÖ÷ÒªµÄ¹¦Ð§ÊÇ»º´æ £¬Í¨¹ý½«Öظ´Ê¹ÓõÄÊý¾Ý»º´æÆðÀ´ £¬¿ÉÒÔïÔÌ­Êý¾Ý¿âÅÌÎʺÍÌá¸ßÓ¦ÓóÌÐòµÄÏìÓ¦ËÙÂÊ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚlaravelÖÐʹÓûº´æ¡£

Laravel»º´æÇý¶¯

LaravelÌṩ¶àÖÖ»º´æÇý¶¯ £¬°üÀ¨Îļþ¡¢Êý¾Ý¿â¡¢Redis¡¢MemcachedµÈ¡£Ä¬ÈÏÇéÐÎÏ £¬LaravelʹÓÃÁËfileÇý¶¯ £¬¼´½«»º´æÊý¾Ý´æ´¢ÔÚÎļþϵͳÖС£ÎÒÃÇ¿ÉÒÔͨ¹ýÐÞ¸ÄÉèÖÃÎļþÀ´Ñ¡ÔñÆäËû»º´æÇý¶¯¡£

ÉèÖÃÎļþλÖãºconfig/cache.php

ÀýÈç £¬ÈôÊÇÎÒÃÇÏëʹÓÃRedis×÷Ϊ»º´æÇý¶¯ £¬¿ÉÒÔƾ֤ÒÔÏ·½·¨ÐÞ¸ÄÉèÖÃÎļþ£º

‘default’ => ‘redis’,

‘redis’ => [

'driver' => 'redis',
'connection' => 'default',

µÇ¼ºó¸´ÖÆ

],

ʹÓûº´æ

µ±Ê¹ÓÃLaravel¾ÙÐÐÊý¾ÝÅÌÎÊʱ £¬ÎÒÃÇ¿ÉÒÔͨ¹ý»º´æÀ´ïÔÌ­Êý¾Ý¿âÅÌÎÊ´ÎÊý¡£ÏÂÃæÊÇÒ»¸öʾÀý´úÂ룺

$users = Cache::remember(‘users’, $minutes, function () {

return DB::table('users')->get();

µÇ¼ºó¸´ÖÆ

});

ÉÏÊö´úÂëʹÓÃCache::rememberÒªÁìÀ´»º´æÅÌÎÊЧ¹û¡£µÚÒ»¸ö²ÎÊýÊÇ»º´æµÄ¼üÃû £¬µÚ¶þ¸ö²ÎÊýÊÇ»º´æµÄʱ¼ä£¨ÒÔ·ÖÖÓΪµ¥Î»£© £¬µÚÈý¸ö²ÎÊýÊÇÒ»¸ö±Õ°üº¯Êý £¬ÓÃÓÚÅÌÎÊÊý¾Ý¿â²¢·µ»ØЧ¹û¡£ÈôÊÇ»º´æÖб£´æ¸Ã¼ü £¬Ôò·µ»Ø»º´æÖеÄÊý¾Ý£»²»È» £¬½«Ö´Ðбհüº¯Êý²¢½«Ð§¹û´æ´¢µ½»º´æÖС£

ÎÒÃÇ»¹¿ÉÒÔʹÓÃCache::putÒªÁìÖ±½Ó½«Êý¾Ý´æ´¢µ½»º´æÖÐ £¬È»ºóʹÓÃCache::getÒªÁì»ñÈ¡»º´æÖеÄÊý¾Ý¡£ÀýÈ磺

Cache::put(‘key’, ‘value’, $minutes);

$value = Cache::get(‘key’);

×Ô½ç˵»º´æÇý¶¯

ÈôÊÇLaravelÌṩµÄ»º´æÇý¶¯²»¿ÉÖª×ãÐèÇó £¬ÎÒÃÇ¿ÉÒÔͨ¹ý×Ô½ç˵»º´æÇý¶¯À´ÊµÏÖ×Ô¼ºµÄ»º´æ¼Æ»®¡£ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄʾÀý£º

Ê×ÏÈ £¬ÔÚconfig/cache.phpÎļþÖнç˵еĻº´æÇý¶¯£º

‘custom’ => [

'driver' => 'custom',
'connection' => null,

µÇ¼ºó¸´ÖÆ

],

È»ºó £¬ÔÚapp/Providers/AppServiceProvider.phpÖÐ×¢²á×Ô½ç˵Çý¶¯£º

use IlluminateSupportFacadesCache;

use IlluminateSupportServiceProvider;

class AppServiceProvider extends ServiceProvider

{

public function register()
{
    Cache::extend('custom', function ($app) {
        return new CustomCacheDriver();
    });
}

µÇ¼ºó¸´ÖÆ

}

×îºó £¬ÔÚCustomCacheDriverÀàÖÐʵÏÖÏêϸµÄ»º´æÂß¼­£º

use IlluminateContractsCacheStore;

class CustomCacheDriver implements Store

{

public function get($key)
{
    // »ñÈ¡»º´æÊý¾Ý
}

public function put($key, $value, $seconds)
{
    // ´æ´¢Êý¾Ýµ½»º´æ
}

// ÆäËûÒªÁì...

µÇ¼ºó¸´ÖÆ

}

×ܽá

±¾ÎÄÏÈÈÝÁËLaravelÖлº´æµÄ»ù±¾Ó÷¨ºÍ×Ô½ç˵»º´æÇý¶¯µÄÒªÁ졣ͨ¹ýºÏÀíµØʹÓûº´æ £¬¿ÉÒÔ´ó´óÌá¸ßÓ¦ÓóÌÐòµÄÐÔÄܺÍÏìÓ¦ËÙÂÊ¡£ÔÚÏÖʵӦÓÃÖÐ £¬ÎÒÃÇÐèҪƾ֤ÏêϸÐèÇóÑ¡ÔñºÏÊʵĻº´æ¼Æ»®ºÍÓÅ»¯Õ½ÂÔ £¬´Ó¶ø×î´óÏ޶ȵØÊ©Õ¹»º´æµÄ×÷Óá£

ÒÔÉϾÍÊÇlaravelÔõôʹÓûº´æµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ