Redis is a noSQL database with very good scaling characteristics
in proportion to the amount of entries and data size.
/** * Constructs this backend * * @param ApplicationContext $context Flow's application context * @param array $options Configuration options - depends on the actual backend * @param \Redis $redis */ public function __construct(ApplicationContext $context, array $options = [], \Redis $redis = null) { $this->context = $context; if ($redis !== null) { $options['redis'] = $redis; } $environmentConfiguration = $this->createEnvironmentConfiguration($context); parent::__construct($environmentConfiguration, $options); }
/** * @test */ public function expiredEntriesAreSkippedWhenIterating() { $this->backend->set('entry1', 'foo', [], 1); sleep(2); $this->assertFalse($this->backend->has('entry1')); $actualEntries = []; foreach ($this->backend as $key => $value) { $actualEntries[] = $key; } $this->assertEmpty($actualEntries, 'Entries should be empty'); }
/** * @test */ public function hasInvokesRedis() { $this->redis->expects($this->once())->method('exists')->with('Foo_Cache:entry:foo')->will($this->returnValue(true)); $this->assertEquals(true, $this->backend->has('foo')); }