@@ -502,12 +502,12 @@ Fortunately, this library allows you to cap the remediation to a certain level.
502502Let's add the ` max_remediation_level ` configuration with ` captcha ` value:
503503
504504``` php
505- $bouncer->configure( [
505+ $configs = [
506506 'api_key' => $bouncerKey,
507507 'api_url' => 'http://crowdsec:8080',
508- 'max_remediation_level ' => 'captcha' // <== ADD THIS LINE!
509- ]
510- ) ;
508+ 'fs_cache_path ' => __DIR__ . '/.cache'
509+ 'max_remediation_level' => 'captcha' // <== ADD THIS LINE
510+ ] ;
511511```
512512
513513Now if you call one more time:
@@ -526,52 +526,33 @@ Now update the `check-ip.php`script to replace the `PhpFilesAdapter` with the `R
526526Replace:
527527
528528``` php
529- <?php
530-
531- require __DIR__ . '/vendor/autoload.php';
532-
533- use CrowdSecBouncer\Bouncer;
534- use Symfony\Component\Cache\Adapter\RedisAdapter;
535-
536- // Init cache adapter
537- $cacheAdapter = new TagAwareAdapter(new PhpFilesAdapter('', 0, __DIR__.'/.cache'));
538-
539- ...
529+ $configs = [
530+ 'api_key' => $bouncerKey,
531+ 'api_url' => 'http://crowdsec:8080',
532+ 'fs_cache_path' => __DIR__ . '/.cache',
533+ ];
540534```
541535
542536with:
543537
544538``` php
545- <?php
546-
547- require __DIR__ . '/vendor/autoload.php';
548-
549- use CrowdSecBouncer\Bouncer;
550- use Symfony\Component\Cache\Adapter\RedisAdapter;
551-
552- // Init cache adapter
553-
554- $cacheAdapter = new RedisTagAwareAdapter(RedisAdapter::createConnection('redis://redis:6379'));
555-
556- ...
539+ $configs = [
540+ 'api_key' => $bouncerKey,
541+ 'api_url' => 'http://crowdsec:8080',
542+ 'cache_system' => 'redis',
543+ 'redis_dsn' => 'redis://redis:6379'
544+ ];
557545```
558546
559547Or, if ` Memcached ` is more adapted than ` Redis ` to your needs:
560548
561549``` php
562- <?php
563-
564- require __DIR__ . '/vendor/autoload.php';
565-
566- use CrowdSecBouncer\Bouncer;
567- use Symfony\Component\Cache\Adapter\MemcachedAdapter;
568-
569- // Init cache adapter
570-
571- $cacheAdapter =
572- new TagAwareAdapter(new MemcachedAdapter(MemcachedAdapter::createConnection('memcached://memcached:11211')));
573-
574- ...
550+ $configs = [
551+ 'api_key' => $bouncerKey,
552+ 'api_url' => 'http://crowdsec:8080',
553+ 'cache_system' => 'memcached',
554+ 'memcached_dsn' => 'memcached://memcached:11211'
555+ ];
575556```
576557
577558You will still be able to verify IPs, but the cache system will be more efficient.
@@ -580,8 +561,6 @@ You will still be able to verify IPs, but the cache system will be more efficien
580561ddev exec php my-own-modules/crowdsec-php-lib/scripts/check-ip.php 1.2.3.4 < BOUNCER_KEY>
581562```
582563
583- > Note: You can try more cache systems but we did not test them for now (Apcu, Filesystem, Doctrine, Couchbase, Pdo). The [ full list is here] ( https://symfony.com/doc/current/components/cache.html#available-cache-adapters ) .
584-
585564### Clear cache script
586565
587566To clear your LAPI cache, you can use the [ ` clear-php ` ] ( ../scripts/clear-cache.php ) script:
0 commit comments