Generate cache key pair (for response header / body) by Host + Uri + Allowed Queries
public generateCacheKeys ( Phalcon\Http\Request $request, array $ignores = [] ) : array | ||
$request | Phalcon\Http\Request | |
$ignores | array | |
return | array |
public function testKeyGenerate() { $interceptor = new DispatchInterceptor(); $cacheKeys = $interceptor->generateCacheKeys($this->request, array()); $expectedKey = md5('example.com' . '/path' . json_encode(array('foo' => 'aaa', 'bar' => 'bbb'))); $this->assertEquals($cacheKeys, array($expectedKey . '_h', $expectedKey . '_b')); $this->assertEquals($interceptor->getCacheHeadersKey(), $expectedKey . '_h'); $this->assertEquals($interceptor->getCacheBodyKey(), $expectedKey . '_b'); //Test igore $cacheKeys = $interceptor->generateCacheKeys($this->request, array('foo')); $expectedKey = md5('example.com' . '/path' . json_encode(array('bar' => 'bbb'))); $this->assertEquals($cacheKeys, array($expectedKey . '_h', $expectedKey . '_b')); $this->assertEquals($interceptor->getCacheHeadersKey(), $expectedKey . '_h'); $this->assertEquals($interceptor->getCacheBodyKey(), $expectedKey . '_b'); }