Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

DoctrineCacheAdapter fails to work #10

Description

@alpha-and-omega

Hello.
Hours wasted without success:

<?php
require_once (__DIR__."/vendor/autoload.php");

use Doctrine\Common\Cache\ApcuCache;
use BehEh\Flaps\Storage\DoctrineCacheAdapter;
use BehEh\Flaps\Flaps;
use BehEh\Flaps\Throttling\LeakyBucketStrategy;
use BehEh\Flaps\Violation\PassiveViolationHandler;

$apc = new ApcuCache();
$apc->setNamespace('MyApplication');
$apc->save('some key', 'my_data');
if( $apc->fetch("some key") != 'my_data' ) die("apcu fail");

$storage = new DoctrineCacheAdapter($apc);
$flaps = new Flaps($storage);

// allow 3 requests per 5 seconds
$flaps->login->setViolationHandler(new PassiveViolationHandler);
$flaps->login->pushThrottlingStrategy(new LeakyBucketStrategy(3, '5s'));
for($i=0;$i<10;$i++)
{
	var_dump($flaps->login->limit('1.2.3.5'));
}

Result:

bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions