Skip to content

Cache Adapter Expiry Error #83

@Artemy-Matvienko

Description

@Artemy-Matvienko

I've used the following 2 issues as references for what I have to do to implement caching with this library. #39 #19

The following is my adapter class for Simple Caching.

namespace App\classes;
use AlexaCRM\CRMToolkit\CacheInterface;
use Symfony\Component\Cache\Simple\FilesystemCache;

class CRMToolkitCacheAdapter implements CacheInterface {
    private $cache;
    
    public function __construct() {
        $this->cache = new FilesystemCache();
    }
    
    public function get( $key, $default = null ){
        return $this->cache->get($key, $default);
    }
    
    public function set( $key, $value, $expiresAfter = null ){
        $this->cache->set($key, $value, $expiresAfter);
    }
    
    public function delete( $key ){
        $this->cache->delete($key);
    }
    
    public function exists( $key ){
        return $this->cache->has($key);
    }
    
    public function cleanup(){
        $this->cache->clear();
    }
}

I've integrated the adapter into my code like so:

$serviceSettings = new Settings( $this->crm_config );
$cacheRepo = new CRMToolkitCacheAdapter();
$this->crm = new Client( $serviceSettings, $cacheRepo );

When I execute my app, I get the following error:

Type: Symfony\Component\Cache\Exception\InvalidArgumentException
Message: Expiration date must be an integer, a DateInterval or null, "double" given
File: /var/www/html/Sources/vendor/symfony/cache/Simple/AbstractCache.php
Line: 163

#0 /var/www/html/Sources/vendor/symfony/cache/Simple/AbstractCache.php(117): Symfony\Component\Cache\Simple\AbstractCache->normalizeTtl(32340)
#1 /var/www/html/Sources/vendor/symfony/cache/Simple/AbstractCache.php(72): Symfony\Component\Cache\Simple\AbstractCache->setMultiple(Array, 32340)
#2 /var/www/html/Sources/src/classes/CRMToolkitCacheAdapter.php(24): Symfony\Component\Cache\Simple\AbstractCache->set('discovery_secur...', Object(AlexaCRM\CRMToolkit\SecurityToken), 32340)
#3 /var/www/html/Sources/vendor/alexacrm/php-crm-toolkit/src/Auth/Authentication.php(104): App\classes\CRMToolkitCacheAdapter->set('discovery_secur...', Object(AlexaCRM\CRMToolkit\SecurityToken), 32340)
#4 /var/www/html/Sources/vendor/alexacrm/php-crm-toolkit/src/Auth/Federation.php(82): AlexaCRM\CRMToolkit\Auth\Authentication->getToken('discovery')
#5 /var/www/html/Sources/vendor/alexacrm/php-crm-toolkit/src/Client.php(1218): AlexaCRM\CRMToolkit\Auth\Federation->generateTokenHeader('discovery')
#6 /var/www/html/Sources/vendor/alexacrm/php-crm-toolkit/src/Client.php(1182): AlexaCRM\CRMToolkit\Client->generateSoapHeader('discovery', 'Execute')
#7 /var/www/html/Sources/vendor/alexacrm/php-crm-toolkit/src/Client.php(868): AlexaCRM\CRMToolkit\Client->generateSoapRequest('discovery', 'Execute', Object(DOMElement))
#8 /var/www/html/Sources/vendor/alexacrm/php-crm-toolkit/src/Client.php(2011): AlexaCRM\CRMToolkit\Client->AlexaCRM\CRMToolkit\{closure}()
#9 /var/www/html/Sources/vendor/alexacrm/php-crm-toolkit/src/Client.php(869): AlexaCRM\CRMToolkit\Client->attemptSoapResponse('discovery', Object(Closure))
#10 /var/www/html/Sources/vendor/alexacrm/php-crm-toolkit/src/Client.php(917): AlexaCRM\CRMToolkit\Client->retrieveOrganizations()
#11 /var/www/html/Sources/vendor/alexacrm/php-crm-toolkit/src/Client.php(166): AlexaCRM\CRMToolkit\Client->retrieveOrganization('https://org...')
#12 /var/www/html/Sources/src/classes/DataSource.php(117): AlexaCRM\CRMToolkit\Client->__construct(Object(AlexaCRM\CRMToolkit\Settings), Object(App\classes\CRMToolkitCacheAdapter))

Any idea what's causing this? "32340" doesn't seem like a double.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions