Zum Inhalt springen

Caching: Unterschied zwischen den Versionen

Aus Computech CMS Wiki
Zeile 81: Zeile 81:


==Memcahced==
==Memcahced==
Drupal:
<code>composer require 'drupal/memcache'</code>
<code>sudo nano /etc/memcached.conf</code>
<code>sudo nano /etc/memcached.conf</code>
<code>service memcached restart</code>
<code>service memcached restart</code>

Version vom 29. August 2022, 09:15 Uhr

Drupal Caching optimieren und verbessern.

Redis

Redis bei Drupal einrichten

Redis caching bei Drupal einrichten composer require drupal/redis drush en -y redis sync PROJEKT drush @live en -y redis folgendes beiweb/sites/default/service.php ergänzen:

// Cusotm Redis Caching (size)
// composer require predis/predis
//
$settings['redis.connection']['interface']    = 'PhpRedis'; // Can be "Predis".
$settings['redis.connection']['host']         = '127.0.0.1';  // Your Redis instance hostname.
$settings['redis.settings']['perm_ttl']       = 1209600; // 14 days
$settings['cache']['default']                 = 'cache.backend.redis';
$settings['queue_default']                    = 'queue.redis';

$settings['redis.connection']['persistent']   = TRUE;   // true
$settings['redis_compress_length']            = 100;    // 100
$settings['redis_compress_level']             = 6;      // 6
$settings['redis.connection']['base']         = 6;      // 12

$settings['container_yamls'][] = $app_root . '/' . $site_path . '/redis.services.yml';


Datei: web/sites/default/redis.services.yml anlegen

# This file contains example services overrides.
#
# Enable with this line in settings.php
#   $settings['container_yamls'][] = 'modules/redis/example.services.yml';
#
# Or copy & paste the desired services into sites/default/services.yml.
#
# Note that the redis module must be enabled for this to work.

services:
  # Cache tag checksum backend. Used by redis and most other cache backend
  # to deal with cache tag invalidations.
  cache_tags.invalidator.checksum:
   class: Drupal\redis\Cache\RedisCacheTagsChecksum
   arguments: ['@redis.factory']
   tags:
     - { name: cache_tags_invalidator }

  # Replaces the default lock backend with a redis implementation.
  lock:
    class: Drupal\Core\Lock\LockBackendInterface
    factory: ['@redis.lock.factory', get]

  # Replaces the default persistent lock backend with a redis implementation.
  lock.persistent:
    class: Drupal\Core\Lock\LockBackendInterface
    factory: ['@redis.lock.factory', get]
    arguments: [true]

  # Replaces the default flood backend with a redis implementation.
  flood:
    class: Drupal\Core\Flood\FloodInterface
    factory: ['@redis.flood.factory', get]

Redis Server installieren

sudo apt update sudo apt install redis-server sudo apt-get install php-redis sudo nano /etc/redis/redis.conf

#CT Custom
maxmemory 2GB
maxmemory-policy allkeys-lru

dies Datei kann wie folgt ergäntzt werden. hz 100 Standard ist hz 10

APCu

php -r "apcu_clear_cache();"  - Cache Leeren

Memcahced

Drupal: composer require 'drupal/memcache'

sudo nano /etc/memcached.conf service memcached restart

#CT Config
-m 2048 # default 64