Kedu ka WordPress si eji Redis mee ngwa ngwa ngwa mgbakwunye cache? CWP na-enyere Redis cache aka

O nwere ike ịbụ na ị nụla maka APC/APCu, Opcache, Xcache, nke nwere ike ime ngwa ngwa WordPress ma ọ bụ ụdị ọ bụla akwadoro script php.

N'ime nkuzi a, m ga-egosi gị otu esi eme ngwa ngwa WordPress site na iji Redis Object Cache, anyị ga-aga n'ihu ịwụnye Redis Cache na CWP, yabụ ka anyị bido

Kedu ihe bụ Redis cache?

  • Redis bụ mbiri nke RE mote DI ctionary Server.
  • Redis bụ isi mmalite mepere emepe, ụlọ ahịa ihe nhazi data bara uru na ebe nchekwa.
  • Redis na-abịa na nhazi data nchekwa nchekwa na-enye gị ohere ịmepụta ngwa ngwa dị iche iche.
  • Isi okwu ojiji maka Redis gụnyere caching, njikwa nnọkọ, bipụta/ịdenye aha, na bọọdụ ndị isi.
  • Redis bụ ụlọ ahịa igodo-uru kacha ewu ewu taa.
  • Redis nwere ikikere BSD, edere ya na koodu C kachasị mma, ma na-akwado ọtụtụ asụsụ mmepe.

Otu esi eme ka nchekwa data Redis cache dị na ogwe njikwa CWP?

Nzọụkwụ 1:Gaa na Ogwe njikwa CWP

  • Họrọ "Ntọala PHP" wee họrọ "PHP Version Switcher";
  • Wee họrọ "PHP Version" na ndetu ndọpụta. A na-atụ aro ka ịwụnye ụdị php 7 ▼ kacha ọhụrụ.
  • Mgbe emegharịrị ibe ahụ, ị ​​ga-ahụ nhọrọ PHP dị maka nrụnye (igbe nlele)

    Kedu ka WordPress si eji Redis mee ngwa ngwa ngwa mgbakwunye cache? CWP na-enyere Redis cache aka

    Gaa na ala wee chọta" redis " wee họrọ ya wee pịa " Build "bọtịnụ, mgbe emechara usoro iwughachi PHP, ị nwere ike ịlele ma redis na-agba ọsọ site na iji iwu na-esonụ▼

    service redis status
    

    Ị ga-enweta mmepụta dị ka nke a (inCentOS A nwalere na 7, CentOS 6 nwere mmepụta dị iche iche, dị ka "na-agba ọsọ").

    [root@demo ~]# service redis status
    Redirecting to /bin/systemctl status redis.service
    ● redis.service - Redis persistent key-value database
    Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
    Drop-In: /etc/systemd/system/redis.service.d
    └─limit.conf
    Active: active (running) since Sun 2022-02-20 16:41:24 +08; 12s ago
    Main PID: 2486 (redis-server)
    Status: "Ready to accept connections"
    CGroup: /system.slice/redis.service
    └─2486 /usr/bin/redis-server 127.0.0.1:6379

    Ihe niile dị mma ugbu a, tinye iwu a ka ịlele ma etinyere php redis▼

    php -m | grep -i redis

    Mpụta ga-adị ka nke a ▼

    [root@demo ~]# php -m | grep -i redis
    redis
    [root@demo ~]#

    Ọ bụrụ na mmepụta bụ redis , Mgbe ahụ, ihe niile dị mma, anyị ga-aga n'ihu ịwụnye WordPress na ntinye Redis.

    Otu esi etinye ogwe njikwa CWP7, biko hụ ebe a ▼

    Otu esi eme ka nkwụnye ihe osooso cache Redis na WordPress?

    Nzọụkwụ 2:Tupu ịmee ngwa mgbakwunye redis-object-cache na WordPress, ị ghaghị wp-config.php Tinye nkọwa ndị a na faịlụ ▼

    define( 'WP_CACHE_KEY_SALT', 'www.chenweiliang.com:' );
    • ga www.chenweiliang.com Jiri webụsaịtị gị dochie anya.

    Ọ bụrụ na enwere m ọtụtụ Redis na otu nkesa, kedu ka m ga-esi hazie ha ka data ahụ ghara ịgwakọta?

    Enwere ụzọ abụọ.

    Ụzọ mbụ bụ ịhazi Redis DB dị iche iche maka saịtị dị iche iche.

    Naanị tinye nhazi ndị a na faịlụ wp-config.php gị ka saịtị dị iche iche wee jiri ọdụ data Redis dị iche iche.

    Ị nwere ike ịtọ ọdụ data Redis dị iche iche na mmụba malite na 0.

    define( 'WP_REDIS_DATABASE', 0 );

    Ụzọ nke abụọ bụ mgbe enweghị ike ịchịkwa Redis na otu nchekwa data ga-eji.

    Mgbe ahụ ị nwere ike itinye nnu dị iche iche na ya, ka data ahụ ghara ịgbagwoju anya ọbụlagodi na ị na-eji otu nchekwa data ▼

    define( 'WP_CACHE_KEY_SALT', 'www.chenweiliang.com:' );

    Nzọụkwụ 3:nbanye na WordPress ndabere → Gaa na "Plugins" → "Wụnye ngwa mgbakwunye" ▼

    Banye na ngalaba nchịkwa WordPress gị → Gaa na "Plugins" → "Tinye Plugins". Ịkwesịrị itinye ngwa mgbakwunye WordPress a: Redis Object Cache.

    Nzọụkwụ 4:Na-eche na ị wụnyela Redis Object cache Ngwa mgbakwunye, ugbu a gaa na Ntọala Redis wee pịa "Kwado Cache Ihe".

    Mgbe WordPress na-enyere aka nkwụnye ntinye cache acceleration Redis, ọ ga-egosipụta "ejikọtara", dị ka egosiri na foto dị n'okpuru ▼

    Mgbe o mechara mee ka ngwa mgbakwunye nchekwa Redis dị na WordPress, ọ ga-egosi "Jikọrọ".

    • kẹle! Agbanyere nkwụnye mgbakwunye cache nke WordPress Redis nke ọma!
    • Ị ga-achọpụta na a na-ebelata ibu ugbu a na ebe nrụọrụ weebụ na-ebu ngwa ngwa ngwa ngwa.

    Nkwupụta pụrụ iche: Ọ bụrụ na mmemme arụnyere ndabara dị n'asụsụ Bekee, a ga-ewere nseta ihuenyo dị ka ihe n'ezie.Ọ bụ na Bekee.

    • Otú ọ dị, ụfọdụ ndị China na-ekwu na "webụsaịtị ndị China na-eji nseta ihuenyo Bekee" na "akụ dị na foto a dị iche"...
    • Enwere ike ịhụ na ndị China a na-egbochi kpamkpam iche echiche efu.
    • Ma eleghị anya, ọ bụ n'ihi na China abụghị obodo mepere emepe na nke nweere onwe ya. Ọ bụrụ na ị na-ekwu ya, ọ dị ka ị nweghị nnwere onwe ikwu okwu na ịmụ Bekee na China?

    Otu esi ahazi nkwụnye ihe osooso cache Redis?

    N'ozuzu, bido ya ozugbo, ma ọ bụ anyị nwere ike ịhazi ya ọzọ.

    Tinye nhazi ndị a na faịlụ wp-config.php anyị▼

    define('WP_REDIS_CLIENT', 'pecl'); // 指定用于与 Redis 通信的客户端, pecl 即 The PHP Extension Community Library
    define('WP_REDIS_SCHEME', 'tcp'); // 指定用于与 Redis 实例进行通信的协议
    define('WP_REDIS_HOST', '127.0.0.1'); // Redis 服务器的 IP 或主机名
    define('WP_REDIS_PORT', '6379'); // Redis 端口
    define('WP_REDIS_DATABASE', '0'); // 接受用于使用该 SELECT 命令自动选择逻辑数据库的数值
    define('WP_CACHE_KEY_SALT', 'www.chenweiliang.com:'); // 设置所有缓存键的前缀( WordPress 多站点模式下使用)
    define('WP_REDIS_MAXTTL', '86400');

    Otu esi elele ma cache Redis ọ dị irè?

    Jiri iwu na-esonụ ka ịlele ma emepụtara cache Redis mpaghara ▼

    redis-cli monitor
    • Tinye webụsaịtị gị, megharịa ibe ahụ, ị ​​ga-ahụ mmepụta data.

    Redis caching nwekwara ike ime ka nkwụnye WordPress na mgbanwe isiokwu WordPress ghara ịrụ ọrụ.

    Iwu ka iji aka hichapụ Redis cache

    redis-cli flushall

    #进入redis
    redis-cli
    
    #清空
    flushall
    
    #退出
    exit

    Lelee nhazi ebe nchekwa nke Redis ▼

    redis-cli info memory

    Weghachite nsonaazụ ajụjụ ▼

    # Memory
    used_memory:24645472
    used_memory_human:23.50M
    used_memory_rss:40558592
    used_memory_rss_human:38.68M
    used_memory_peak:140777552
    used_memory_peak_human:134.26M
    used_memory_peak_perc:17.51%
    used_memory_overhead:1619888
    used_memory_startup:811872
    used_memory_dataset:23025584
    used_memory_dataset_perc:96.61%
    allocator_allocated:24964648
    allocator_active:26865664
    allocator_resident:37646336
    total_system_memory:17179869184
    total_system_memory_human:16.00G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    used_memory_scripts:0
    used_memory_scripts_human:0B
    number_of_cached_scripts:0
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    allocator_frag_ratio:1.08
    allocator_frag_bytes:1901016
    allocator_rss_ratio:1.40
    allocator_rss_bytes:10780672
    rss_overhead_ratio:1.08
    rss_overhead_bytes:2912256
    mem_fragmentation_ratio:1.65
    mem_fragmentation_bytes:15954144
    mem_not_counted_for_evict:0
    mem_replication_backlog:0
    mem_clients_slaves:0
    mem_clients_normal:20496
    mem_aof_buffer:0
    mem_allocator:jemalloc-5.1.0
    active_defrag_running:0
    lazyfree_pending_objects:0
    lazyfreed_objects:0

    Ihe na-esonụ bụ otu esi ahazi faịlụ pid mgbe ịmalitere cache Redis▼

    Dozie nsogbu nke ihe nkesa Redis anaghị ebido

    Mgbe ịmalitegharịrị ihe nkesa VPS, ihe nkesa Redis nwere ike ọ gaghị enwe ike ịnweta njikọ dịpụrụ adịpụ.

    Nsogbu mmalite mmalite nkesa Redis: dozie nsogbu ịmalitegharị na enweghị ike ịnweta njikọ dịpụrụ adịpụ

    Ị nwere ike iji systemd iji mee ụdị Redis kachasị ọhụrụ. Ịkwesịrị idezi faịlụ nhazi Redis:

    /etc/redis.conf

    Wulite ma hazie Redis site na nkwado sistemu ▼

    daemonize no

    supervised auto
    • Gbalịa ịmalitegharị ihe nkesa VPS Ọ bụrụ na Redis nwere ike ịmalite dị ka ọ dị na mbụ, ọ pụtara na faịlụ nhazi Redis ka deziri ọrụ.

    评论

    Agaghị ebipụta adreesị ozi-e gị. Achọrọ ubi na-eji * Label

    Pịgharịa gaa na n'elu