Commit a3d58e7b authored by romanb's avatar romanb

[2.0] Fixed array tests by removing tests for ArrayCache specific methods from...

[2.0] Fixed array tests by removing tests for ArrayCache specific methods from the tests of other cache drivers. Some general API work on the cache interface.
parent 0c8a35f7
...@@ -34,38 +34,36 @@ namespace Doctrine\Common\Cache; ...@@ -34,38 +34,36 @@ namespace Doctrine\Common\Cache;
interface Cache interface Cache
{ {
/** /**
* Test if a cache entry is available for the given id and (if yes) return it (false else). * Fetches an entry from the cache.
* *
* Note : return value is always "string" (unserialization is done by the core not by the backend) * @param string $id cache id The id of the cache entry to fetch.
* * @return string The cached data or FALSE, if no cache entry exists for the given id.
* @param string $id cache id
* @return string cached datas (or false)
*/ */
public function fetch($id); function fetch($id);
/** /**
* Test if a cache is available or not (for the given id) * Test if an entry exists in the cache.
* *
* @param string $id cache id * @param string $id cache id The cache id of the entry to check for.
* @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record * @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise.
*/ */
public function contains($id); function contains($id);
/** /**
* Puts data into the cache. * Puts data into the cache.
* *
* @param string $id cache id * @param string $id The cache id.
* @param string $data data to cache * @param string $data The cache entry/data.
* @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime) * @param int $lifeTime The lifetime. If != false, sets a specific lifetime for this cache entry (null => infinite lifeTime).
* @return boolean true if no problem * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise.
*/ */
public function save($id, $data, $lifeTime = false); function save($id, $data, $lifeTime = false);
/** /**
* Remove a cache record * Deletes a cache entry.
* *
* @param string $id cache id * @param string $id cache id
* @return boolean true if no problem * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise.
*/ */
public function delete($id); function delete($id);
} }
\ No newline at end of file
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
namespace Doctrine\Common\Cache; namespace Doctrine\Common\Cache;
use \Memcache;
/** /**
* Memcache cache driver. * Memcache cache driver.
* *
...@@ -33,7 +35,7 @@ namespace Doctrine\Common\Cache; ...@@ -33,7 +35,7 @@ namespace Doctrine\Common\Cache;
class MemcacheCache implements Cache class MemcacheCache implements Cache
{ {
/** /**
* @var Memcache $_memcache memcache object * @var Memcache
*/ */
private $_memcache; private $_memcache;
......
...@@ -28,8 +28,8 @@ use \ArrayAccess; ...@@ -28,8 +28,8 @@ use \ArrayAccess;
use \ArrayIterator; use \ArrayIterator;
/** /**
* A Collection is a thin wrapper around a php array. Think of it as an OO version * A Collection is a thin wrapper around a php array. Like a php array it is essentially
* of a plain array. * an ordered map.
* *
* @author Roman S. Borschel <roman@code-factory.org> * @author Roman S. Borschel <roman@code-factory.org>
* @since 2.0 * @since 2.0
...@@ -42,10 +42,10 @@ class Collection implements Countable, IteratorAggregate, ArrayAccess ...@@ -42,10 +42,10 @@ class Collection implements Countable, IteratorAggregate, ArrayAccess
* *
* @var array * @var array
*/ */
protected $_elements = array(); protected $_elements;
/** /**
* Constructor accepts an array of $elements * Initializes a new Collection.
* *
* @param array $elements * @param array $elements
*/ */
......
...@@ -28,16 +28,9 @@ class ApcCacheTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -28,16 +28,9 @@ class ApcCacheTest extends \Doctrine\Tests\DoctrineTestCase
// Test fetch // Test fetch
$this->assertEquals('testing this out', $cache->fetch('test_key')); $this->assertEquals('testing this out', $cache->fetch('test_key'));
// Test count
$this->assertEquals(1, $cache->count());
// Test delete // Test delete
$cache->save('test_key2', 'test2'); $cache->save('test_key2', 'test2');
$cache->delete('test_key2'); $cache->delete('test_key2');
$this->assertFalse($cache->contains('test_key2')); $this->assertFalse($cache->contains('test_key2'));
// Test delete all
$cache->deleteAll();
$this->assertEquals(0, $cache->count());
} }
} }
\ No newline at end of file
...@@ -28,16 +28,9 @@ class MemcacheCacheTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -28,16 +28,9 @@ class MemcacheCacheTest extends \Doctrine\Tests\DoctrineTestCase
// Test fetch // Test fetch
$this->assertEquals('testing this out', $cache->fetch('test_key')); $this->assertEquals('testing this out', $cache->fetch('test_key'));
// Test count
$this->assertEquals(1, $cache->count());
// Test delete // Test delete
$cache->save('test_key2', 'test2'); $cache->save('test_key2', 'test2');
$cache->delete('test_key2'); $cache->delete('test_key2');
$this->assertFalse($cache->contains('test_key2')); $this->assertFalse($cache->contains('test_key2'));
// Test delete all
$cache->deleteAll();
$this->assertEquals(0, $cache->count());
} }
} }
\ No newline at end of file
...@@ -28,16 +28,9 @@ class XcacheCacheTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -28,16 +28,9 @@ class XcacheCacheTest extends \Doctrine\Tests\DoctrineTestCase
// Test fetch // Test fetch
$this->assertEquals('testing this out', $cache->fetch('test_key')); $this->assertEquals('testing this out', $cache->fetch('test_key'));
// Test count
$this->assertEquals(1, $cache->count());
// Test delete // Test delete
$cache->save('test_key2', 'test2'); $cache->save('test_key2', 'test2');
$cache->delete('test_key2'); $cache->delete('test_key2');
$this->assertFalse($cache->contains('test_key2')); $this->assertFalse($cache->contains('test_key2'));
// Test delete all
$cache->deleteAll();
$this->assertEquals(0, $cache->count());
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment