@@ -502,12 +502,12 @@ Fortunately, this library allows you to cap the remediation to a certain level.
502
502
Let's add the ` max_remediation_level ` configuration with ` captcha ` value:
503
503
504
504
``` php
505
- $bouncer->configure( [
505
+ $configs = [
506
506
'api_key' => $bouncerKey,
507
507
'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
+ ] ;
511
511
```
512
512
513
513
Now if you call one more time:
@@ -526,52 +526,33 @@ Now update the `check-ip.php`script to replace the `PhpFilesAdapter` with the `R
526
526
Replace:
527
527
528
528
``` 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
+ ];
540
534
```
541
535
542
536
with:
543
537
544
538
``` 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
+ ];
557
545
```
558
546
559
547
Or, if ` Memcached ` is more adapted than ` Redis ` to your needs:
560
548
561
549
``` 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
+ ];
575
556
```
576
557
577
558
You 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
580
561
ddev exec php my-own-modules/crowdsec-php-lib/scripts/check-ip.php 1.2.3.4 < BOUNCER_KEY>
581
562
```
582
563
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
-
585
564
### Clear cache script
586
565
587
566
To clear your LAPI cache, you can use the [ ` clear-php ` ] ( ../scripts/clear-cache.php ) script:
0 commit comments