|
|
| (2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) |
| Zeile 9: |
Zeile 9: |
| ===Redis bei Drupal einrichten=== | | ===Redis bei Drupal einrichten=== |
| [[Redis caching bei Drupal einrichten]] | | [[Redis caching bei Drupal einrichten]] |
|
| |
| <code>composer require drupal/redis</code>
| |
| folgendes bei '''<code>sudo nano web/sites/default/settings.php</code>''' ergänzen:
| |
| <code>drush en -y redis</code>
| |
| * settings.php
| |
| <syntaxhighlight line='line' lang="php">
| |
| /**
| |
| * Caching Einstellungen ************************************************
| |
| */
| |
| // Redis Variablen
| |
| $redis_prefix = 'dev9_'; # kurzer Name (string)
| |
| $redis_db = 1; # 1 - 12 (INT)
| |
| /**
| |
| * Redis Caching einstellungen.
| |
| */
| |
| // Redis installeiren.
| |
| // $ composer require predis/predis drupal/redis && drush en -y redis
| |
| //
| |
| // $settings['redis.connection']['interface'] = 'Predis'; // 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['cache']['bins']['render'] = 'cache.backend.redis';
| |
| // $settings['queue_default'] = 'queue.redis';
| |
| // $settings['queue_service_aggregator_feeds'] = 'queue.redis';
| |
| // $settings['redis_perm_ttl_cache_field'] = 2592000; // 30 days.
| |
| // $settings['redis.connection']['persistent'] = TRUE; // true
| |
| // $settings['redis_compress_length'] = 100; // 100
| |
| // $settings['redis_compress_level'] = 6; // 6
| |
| // $settings['redis.connection']['base'] = $redis_db; // 1
| |
| // $settings['redis.compression']['enabled'] = TRUE; // true
| |
| // $settings['redis.compression']['size_threshold'] = 200; // 200
| |
| // $settings['redis.compression']['ratio'] = 2; // 2
| |
| // $settings['cache_prefix']['default'] = $redis_prefix;
| |
| // $settings['container_yamls'][] = $app_root . '/' . $site_path . '/redis.services.yml';
| |
| /**
| |
| * Redis Caching ende ****************************************************
| |
| */
| |
| </syntaxhighlight>
| |
|
| |
|
| |
| Datei: '''sudo nano <code>web/sites/default/redis.services.yml</code>''' anlegen
| |
| <syntaxhighlight line='line' lang="yaml">
| |
| # 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]
| |
|
| |
| </syntaxhighlight>
| |
| <code>sync PROJEKT</code>
| |
| <code>drush @live en -y redis</code>
| |
|
| |
|
| ===Redis Server installieren=== | | ===Redis Server installieren=== |
| Zeile 110: |
Zeile 30: |
| </syntaxhighlight> | | </syntaxhighlight> |
| ===Redis Cache Leeren=== | | ===Redis Cache Leeren=== |
| * <code>redis-cli FLUSHDB</code> | | * <code>redis-cli FLUSHDB && redis-cli FLUSHALL</code> |
| * <code>redis-cli FLUSHALL</code>
| |
|
| |
|
| ==APCu== | | ==APCu== |
Drupal Caching optimieren und verbessern.
Allgemeiner Cache leeren
SWP Leeren: sudo swapoff -a && sudo swapon -a
Apache
Apache Cache leeren: sudo service apache2 graceful
Redis
Redis bei Drupal einrichten
Redis caching bei Drupal einrichten
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
Auf CT Server
#CT Custom
maxmemory 2147483648
maxmemory-policy allkeys-lru
hz 30
Redis Cache Leeren
redis-cli FLUSHDB && redis-cli FLUSHALL
APCu
php -r "apcu_clear_cache();" - Cache Leeren
Einstellungen
sudo nano /etc/php/8.1/mods-available/apcu.ini
#CT Custom
extension=apcu.so
apc.enabled=1
apc.ttl=604800
apc.user_ttl=3600
apc.shm_size=256M
apc.include_once_override=1
auto_globals_jit=Off
apc.num_files_hint = 2048
apc.stat_ctime = 0
apc.file_update_protection = 2
apc.stat = 0
Memcache
Drupal Memcahce
composer require 'drupal/memcache'
Einstellungen in der settings.php (vor Reids)
$settings['memcache']['servers'] = ['127.0.0.1:11211' => 'default'];
$settings['memcache']['bins'] = ['default' => 'default'];
$settings['memcache']['key_prefix'] = '';
//$settings['cache']['default'] = 'cache.backend.memcache';
$settings['cache']['bins']['render'] = 'cache.backend.memcache';
Server
sudo nano /etc/memcached.conf
sudo systemctl restart memcached
#CT Config
-m 2048 # default 64
Befehle
Clear Cache: echo 'flush_all' | nc localhost 11211