Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into rfc/escaper
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 151 deletions.
8 changes: 1 addition & 7 deletions src/Container/AbstractContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,16 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Memory\Container;

use Zend\Memory\Container;

/**
* Memory value container
*
* @uses \Zend\Memory\Container
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AbstractContainer implements Container
abstract class AbstractContainer implements ContainerInterface
{
}
14 changes: 3 additions & 11 deletions src/Container/AccessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Memory\Container;

use Zend\Memory\Container;

/**
* Memory object container access controller.
*
Expand All @@ -37,27 +32,25 @@
*
* Class also provides Zend\Memory\Container interface and works as proxy for such cases.
*
* @uses \Zend\Memory\Container
* @uses \Zend\Memory\Container\Movable
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class AccessController implements Container
class AccessController implements ContainerInterface
{
/**
* Memory container object
*
* @var \Zend\Memory\Container\AbstractContainer
* @var Movable
*/
private $_memContainer;


/**
* Object constructor
*
* @param \Zend\Memory\Container\Movable $memContainer
* @param Movable $memContainer
*/
public function __construct(Movable $memContainer)
{
Expand Down Expand Up @@ -131,7 +124,6 @@ public function isLocked()
*
* @param string $property
* @return string
* @throws \Zend\Memory\Exception
*/
public function __get($property)
{
Expand Down
7 changes: 2 additions & 5 deletions src/Container.php → src/Container/ContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Memory;
namespace Zend\Memory\Container;

/**
* Memory value container interface
Expand All @@ -31,7 +28,7 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Container
interface ContainerInterface
{
/**
* Get string value reference
Expand Down
4 changes: 0 additions & 4 deletions src/Container/Locked.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Memory\Container;

/**
* Memory value container
*
* Locked (always stored in memory).
*
* @uses \Zend\Memory\Container\AbstractContainer
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down
9 changes: 2 additions & 7 deletions src/Container/Movable.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Memory\Container;

use Zend\Memory,
Zend\Memory\Exception;

Expand All @@ -30,9 +28,6 @@
*
* Movable (may be swapped with specified backend and unloaded).
*
* @uses \Zend\Memory\Container\AbstractContainer
* @uses \Zend\Memory\Exception
* @uses \Zend\Memory\Value
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down Expand Up @@ -134,7 +129,7 @@ public function isLocked()
*
* @param string $property
* @return string
* @throws \Zend\Memory\Exception
* @throws Exception\InvalidArgumentException
*/
public function __get($property)
{
Expand Down
7 changes: 2 additions & 5 deletions src/Exception.php → src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Memory;
namespace Zend\Memory\Exception;

/**
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Exception
interface ExceptionInterface
{}

9 changes: 2 additions & 7 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,18 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Memory\Exception;
use Zend\Memory\Exception;

/**
* Exception for Zend_Memory component.
*
* @uses Zend\Exception
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InvalidArgumentException
extends \InvalidArgumentException
implements Exception
implements ExceptionInterface
{
}
}
9 changes: 2 additions & 7 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,18 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Memory\Exception;
use Zend\Memory\Exception;

/**
* Exception for Zend_Memory component.
*
* @uses Zend\Exception
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class RuntimeException
extends \RuntimeException
implements Exception
implements ExceptionInterface
{
}
}
38 changes: 17 additions & 21 deletions src/MemoryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Memory;

use Zend\Cache\Storage\Adapter as CacheAdapter;
use Zend\Cache\Storage\ClearByNamespaceInterface;

use Zend\Cache\Storage\StorageInterface as CacheStorage,
Zend\Cache\Storage\ClearByNamespaceInterface as ClearByNamespaceCacheStorage,
Zend\Cache\Storage\FlushableInterface as FlushableCacheStorage;

/**
* Memory manager
Expand All @@ -41,7 +42,7 @@ class MemoryManager
/**
* Storage cache object
*
* @var CacheAdapter
* @var CacheStorage
*/
private $_cache = null;

Expand Down Expand Up @@ -121,13 +122,6 @@ class MemoryManager
*/
private $_managerId;

/**
* Tags array, used by backend to categorize stored values
*
* @var array
*/
private $_tags;

/**
* This function is intended to generate unique id, used by memory manager
*/
Expand All @@ -139,20 +133,18 @@ private function _generateMemManagerId()
* it should be changed by something else
* (Ex. backend interface should be extended to provide this functionality)
*/
$this->_managerId = str_replace('.', '_', uniqid('ZendMemManager', true));
$this->_tags = array($this->_managerId);
$this->_managerId .= '_';
$this->_managerId = str_replace('.', '_', uniqid('ZendMemManager', true)) . '_';
}

/**
* Memory manager constructor
*
* If cache is not specified, then memory objects are never swapped
*
* @param CacheAdapter $cache
* @param CacheStorage $cache
* @return void
*/
public function __construct(CacheAdapter $cache = null)
public function __construct(CacheStorage $cache = null)
{
if ($cache === null) {
return;
Expand Down Expand Up @@ -186,12 +178,16 @@ public function __construct(CacheAdapter $cache = null)
/**
* Object destructor
*
* Clean up backend storage
* Clean up cache storage
*/
public function __destruct()
{
if ($this->_cache !== null) {
$this->_cache->clear(CacheAdapter::MATCH_TAGS_OR, array('tags' => $this->_tags));
if ($this->_cache instanceof ClearByNamespaceCacheStorage) {
$this->_cache->clearByNamespace($this->_cache->getOptions()->getNamespace());
} elseif ($this->_cache instanceof FlushableCacheStorage) {
$this->_cache->flush();
}
}
}

Expand Down Expand Up @@ -418,7 +414,7 @@ private function _swap(Container\Movable $container, $id)
}

if (!$container->isSwapped()) {
$this->_cache->setItem($this->_managerId . $id, $container->getRef(), array('tags' => $this->_tags));
$this->_cache->setItem($this->_managerId . $id, $container->getRef());
}

$this->_memorySize -= $this->_sizes[$id];
Expand All @@ -436,7 +432,7 @@ private function _swap(Container\Movable $container, $id)
*/
public function load(Container\Movable $container, $id)
{
$value = $this->_cache->getItem($this->_managerId . $id, array('ttl' => 0));
$value = $this->_cache->getItem($this->_managerId . $id);

// Try to swap other objects if necessary
// (do not include specified object into check)
Expand Down
12 changes: 5 additions & 7 deletions src/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,23 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Memory;

use ArrayAccess,
Countable;

/**
* String value object
*
* It's an OO string wrapper.
* Used to intercept string updates.
*
* @uses ArrayAccess
* @uses Countable
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Value implements \ArrayAccess,\Countable
class Value implements ArrayAccess, Countable
{
/**
* Value
Expand All @@ -48,7 +46,7 @@ class Value implements \ArrayAccess,\Countable
/**
* Container
*
* @var \Zend\Memory\Container
* @var Container\Movable
*/
private $_container;

Expand Down
Loading

0 comments on commit f70afcc

Please sign in to comment.