Add getStats() method for MemoryCaches

This commit is contained in:
Philipp 2025-04-21 19:37:37 +02:00
parent ffb621f0e4
commit 01296e98f9
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
12 changed files with 170 additions and 0 deletions

View file

@ -35,4 +35,18 @@ class APCuCacheTest extends MemoryCacheTestCase
$this->cache->clear(false);
parent::tearDown();
}
/**
* @small
*/
public function testStats()
{
$stats = $this->instance->getStats();
self::assertNotNull($stats['entries']);
self::assertNotNull($stats['used_memory']);
self::assertNotNull($stats['hits']);
self::assertNotNull($stats['misses']);
self::assertNotNull($stats['avail_mem']);
}
}

View file

@ -59,4 +59,21 @@ class MemcacheCacheTest extends MemoryCacheTestCase
{
static::markTestIncomplete('Race condition because of too fast getAllKeys() which uses a workaround');
}
/**
* @small
*/
public function testStats()
{
$stats = $this->instance->getStats();
self::assertNotNull($stats['version']);
self::assertIsNumeric($stats['hits']);
self::assertIsNumeric($stats['misses']);
self::assertIsNumeric($stats['evictions']);
self::assertIsNumeric($stats['entries']);
self::assertIsNumeric($stats['used_memory']);
self::assertGreaterThan(0, $stats['connected_clients']);
self::assertGreaterThan(0, $stats['uptime']);
}
}

View file

@ -58,4 +58,21 @@ class MemcachedCacheTest extends MemoryCacheTestCase
{
static::markTestIncomplete('Race condition because of too fast getAllKeys() which uses a workaround');
}
/**
* @small
*/
public function testStats()
{
$stats = $this->instance->getStats();
self::assertNotNull($stats['version']);
self::assertIsNumeric($stats['hits']);
self::assertIsNumeric($stats['misses']);
self::assertIsNumeric($stats['evictions']);
self::assertIsNumeric($stats['entries']);
self::assertIsNumeric($stats['used_memory']);
self::assertGreaterThan(0, $stats['connected_clients']);
self::assertGreaterThan(0, $stats['uptime']);
}
}

View file

@ -57,4 +57,21 @@ class RedisCacheTest extends MemoryCacheTestCase
$this->cache->clear(false);
parent::tearDown();
}
/**
* @small
*/
public function testStats()
{
$stats = $this->instance->getStats();
self::assertNotNull($stats['version']);
self::assertIsNumeric($stats['hits']);
self::assertIsNumeric($stats['misses']);
self::assertIsNumeric($stats['evictions']);
self::assertIsNumeric($stats['entries']);
self::assertIsNumeric($stats['used_memory']);
self::assertGreaterThan(0, $stats['connected_clients']);
self::assertGreaterThan(0, $stats['uptime']);
}
}