尊龙凯时人生就是博

laravel ÅÌÎÊ»º´æ

laravelÊÇÒ»¸öÊ¢ÐеÄphp web¿ò¼Ü£¬ËüÔÚweb¿ª·¢ÖÐÆÕ±éʹÓá£ËüµÄÅÌÎʹ¹½¨Æ÷ÔÊÐíÄãÒÔÓÅÑŵķ½·¨¹¹½¨Êý¾Ý¿âÅÌÎÊ£¬´æ´¢¿âģʽºÍÑùʽ¡£¿ÉÊÇ£¬laravel ormµÄÅÌÎÊÓÐʱ»á·Ç³£»ºÂý£¬Õâ¿ÉÄÜ»áÓ°ÏìÓ¦ÓóÌÐòµÄÐÔÄÜ¡£½â¾öÕâ¸öÎÊÌâµÄÒ»ÖÖÒªÁìÊÇʹÓÃlaravelµÄÅÌÎÊ»º´æ¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«ÏÈÈÝlaravelÅÌÎÊ»º´æµÄ¿´·¨ºÍÔõÑùÔÚlaravelÖÐʹÓÃËü¡£

ʲôÊÇÅÌÎÊ»º´æ?

ÅÌÎÊ»º´æÊÇÒ»ÖÖ»º´æÊÖÒÕ£¬¿ÉÓÃÓÚïÔÌ­SQLÅÌÎʵÄÖ´ÐÐʱ¼ä¡£ÔÚÅÌÎÊ»º´æÖУ¬Ê×´ÎÔËÐÐÅÌÎÊʱ£¬Ð§¹û½«±»»º´æÆðÀ´£¬ÒÔ±ãÒÔºóÖظ´Ö´ÐиÃÅÌÎÊʱ£¬¿ÉÒÔÖ±½Ó´Ó»º´æÖлñȡЧ¹û£¬¶øÎÞÐèÖØÐÂÖ´ÐÐÅÌÎÊ¡£Õâ¿ÉÒÔÏÔÖøïÔÌ­ÅÌÎʵÄÖ´ÐÐʱ¼ä£¬´Ó¶øÌá¸ßÓ¦ÓóÌÐòµÄÐÔÄÜ¡£

ÔÚLaravelÖУ¬ÅÌÎÊ»º´æʹÓûº´æÇý¶¯³ÌÐòÀ´´æ´¢ÅÌÎÊЧ¹û¡£Äú¿ÉÒÔÑ¡ÔñÈκλº´æÇý¶¯³ÌÐò£¬ÀýÈçmemcached£¬Redis»òÎļþ»º´æµÈ¡£Laravel»¹ÌṩÁËÒ»¸ö¼òÆÓµÄAPI£¬Ê¹Äú¿ÉÒÔÇáËɵØʹÓûº´æÇý¶¯³ÌÐò¡£

LaravelÅÌÎÊ»º´æµÄÓï·¨

ÔÚLaravelÖУ¬ÅÌÎÊ»º´æ¿ÉÒÔʹÓÃcache()ÒªÁìÀ´ÊµÏÖ¡£ÏÂÃæÊÇʹÓÃÅÌÎÊ»º´æµÄ»ù±¾Óï·¨£º

$users = DB::table(‘users’)

            ->where('name', 'John')
            ->cache(10) // »º´æ10·ÖÖÓ
            ->get();

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄÀý×ÓÖУ¬ÎÒÃÇÊ×ÏÈʹÓÃDB£º£ºtable()ÒªÁìÀ´Ö¸¶¨ÒªÅÌÎʵÄÊý¾Ý¿â±í¡£È»ºóÎÒÃÇʹÓÃwhere()ÒªÁìÀ´Ìí¼ÓÏÞÖÆÌõ¼þ£¬×îºóʹÓÃget()ÒªÁìÀ´Ö´ÐÐÅÌÎÊ¡£Óë´Ëͬʱ£¬ÎÒÃÇʹÓÃcache()ÒªÁìÀ´ÆôÓÃÅÌÎÊ»º´æ£¬¸ÃÒªÁì½ÓÊÜÒ»¸öʱ¼ä²ÎÊý£¬ÒÔÖ¸¶¨»º´æµÄʱ¼ä¡£

ÔõÑùÉèÖÃÅÌÎÊ»º´æ

ÔÚʹÓÃÅÌÎÊ»º´æ֮ǰ£¬ÄúÐèÒªÏÈÉèÖûº´æÇý¶¯³ÌÐò¡£LaravelÖ§³Ö¶àÖÖ»º´æÇý¶¯³ÌÐò£¬°üÀ¨Îļþ»º´æ£¬memcached»º´æºÍRedis»º´æµÈ¡£Äú¿ÉÒÔƾ֤ÄúµÄÐèҪѡÔñÊʵ±µÄ»º´æÇý¶¯³ÌÐò¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«Ê¹ÓÃÎļþ»º´æÀ´ÑÝʾ¡£

ÒªÉèÖÃÎļþ»º´æ£¬Çë·­¿ªconfig/cache.phpÎļþ£¬Äú½«¿´µ½ÒÔÏÂÄÚÈÝ£º

return [

/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache "store" that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis", "dynamodb"
|
*/

'default' => env('CACHE_DRIVER', 'file'),

/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same driver to group types of items stored in your caches.
|
*/

'stores' => [

    'apc' => [
        'driver' => 'apc',
    ],

    'array' => [
        'driver' => 'array',
    ],

    'database' => [
        'driver' => 'database',
        'table' => 'cache',
        'connection' => null,
    ],

    'file' => [
        'driver' => 'file',
        'path' => storage_path('framework/cache/data'),
    ],

    'memcached' => [
        'driver' => 'memcached',
        'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
        'sasl' => [
            env('MEMCACHED_USERNAME'),
            env('MEMCACHED_PASSWORD'),
        ],
        'options' => [
            // Memcached::OPT_CONNECT_TIMEOUT => 2000,
        ],
        'servers' => [
            [
                'host' => env('MEMCACHED_HOST', '127.0.0.1'),
                'port' => env('MEMCACHED_PORT', 11211),
                'weight' => env('MEMCACHED_WEIGHT', 100),
            ],
        ],
    ],

    'redis' => [
        'driver' => 'redis',
        'connection' => 'cache',
    ],

],

/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/

'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),

µÇ¼ºó¸´ÖÆ

];

ÔÚÉÏÃæµÄÉèÖÃÎļþÖУ¬Äú¿ÉÒÔ¿´µ½’LaravelÖ§³Ö¶àÖÖ»º´æÇý¶¯³ÌÐòµÄ²¿·Ö¡£’file’Çý¶¯³ÌÐòʹÓÃÎļþϵͳÀ´´æ´¢»º´æ¡£Äú¿ÉÒÔ¸ü¸Äpath’Ñ¡ÏîµÄÖµÒÔÖ¸¶¨Òª´æ´¢»º´æµÄĿ¼¡£Ä¬ÈÏÇéÐÎÏ£¬ËùÓеĻº´æ¶¼´æ´¢ÔÚstorage/framework/cache/dataĿ¼ÖС£

ʹÓÃÅÌÎÊ»º´æºóµÄ×¢ÖØÊÂÏî

ÔÚʹÓÃÅÌÎÊ»º´æʱ£¬Óм¸¸öҪעÖصÄÊÂÏî¡£Ê×ÏÈ£¬ÅÌÎÊ»º´æÖ»¶ÔÖ´ÐÐÅÌÎʺ󷵻ØЧ¹ûµÄÅÌÎÊÓÐÓá£ÈôÊÇÄúÕýÔÚÖ´ÐÐÐÞ¸ÄÊý¾Ý¿âµÄÅÌÎÊ£¬ÀýÈçINSERT£¬UPDATEºÍDELETEÅÌÎÊ£¬ÔòÅÌÎÊ»º´æ½«²»»áÆð×÷Óá£Æä´Î£¬ÅÌÎÊ»º´æÖ»¶ÔͨÀýÅÌÎÊÓÐÓá£ÈôÊÇÄúµÄÅÌÎÊ°üÀ¨Ëæ»úÔªËØ£¬ÀýÈçʱ¼ä´Á»òGUID£¬ÔòÅÌÎÊ»º´æ½«²»Æð×÷Óá£×îºó£¬ÅÌÎÊ»º´æÖ»Ó¦ÔÚÅÌÎÊЧ¹ûÏÕЩ²»»áת±äµÄÇéÐÎÏÂʹÓá£ÈôÊÇÄúµÄÅÌÎÊЧ¹û¾­³£¸ü¸Ä£¬ÔòʹÓÃÅÌÎÊ»º´æ¿ÉÄܻᵼÖ²»×¼È·µÄЧ¹û¡£

½áÂÛ

LaravelÅÌÎÊ»º´æÊÇÒ»ÖÖïÔÌ­SQLÅÌÎÊÖ´ÐÐʱ¼äµÄÇ¿Ê¢¹¤¾ß¡£ÔÚ¿ª·¢´óÐÍWebÓ¦ÓóÌÐòʱ£¬ÐÔÄÜÎÊÌâʼÖÕÊÇÒ»¸öÁîÈ˵£ÐĵÄÎÊÌ⡣ͨ¹ýʹÓÃLaravelÅÌÎÊ»º´æ£¬Äú¿ÉÒÔÏÔÖøÌá¸ßÄúµÄÓ¦ÓóÌÐòµÄÐÔÄÜ£¬²¢Ìṩ¸ü¿ìµÄÏìӦʱ¼ä¡£ÔÚʵÑéÅÌÎÊ»º´æʱ£¬Çë×¢ÖØÎÒÃÇÌáµ½µÄÒªµãºÍ×¢ÖØÊÂÏ²¢Æ¾Ö¤ÐèҪѡÔñÊʵ±µÄ»º´æÇý¶¯³ÌÐò¡£

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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