Skip to content

Commit

Permalink
Added SHM::__invoke() as a shortcut to SHM::add();
Browse files Browse the repository at this point in the history
Minor fixes to the PHAR stub;
Release notes.
  • Loading branch information
boenrobot committed Sep 25, 2012
1 parent 08c79ad commit 92a7d1a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions RELEASE-0.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
First PEAR2 compatible release.
4 changes: 4 additions & 0 deletions RELEASE-0.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Fixed the PHAR stub.
* Removed the warnings APC would trigger when using SHM::factory().
* Allowed registering of external adapters with the new SHM::registerAdapter() method.
* Added SHM::__invoke() as a shortcut to SHM::add().
12 changes: 8 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@
<email>[email protected]</email>
<active>yes</active>
</lead>
<date>2012-08-03</date>
<time>00:53:00</time>
<date>2012-09-25</date>
<time>23:15:45</time>
<version>
<release>0.1.0</release>
<release>0.1.1</release>
<api>0.1.0</api>
</version>
<stability>
<release>alpha</release>
<api>alpha</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL License 2.1</license>
<notes>First PEAR2 compatible release.</notes>
<notes>* Fixed the PHAR stub.
* Removed the warnings APC would trigger when using SHM::factory().
* Allowed registering of external adapters with the new SHM::registerAdapter() method.
* Added SHM::__invoke() as a shortcut to SHM::add().</notes>
<contents>
<dir name="/">
<dir name="docs" baseinstalldir="/">
<file role="doc" name="apigen.neon"/>
<file role="doc" name="doxygen.ini">
<tasks:replace from="../src" to="php_dir" type="pear-config"/>
<tasks:replace from="GIT: $Id$" to="version" type="package-info"/>
Expand Down
21 changes: 20 additions & 1 deletion src/PEAR2/Cache/SHM.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public static function registerAdapter($adapter, $prepend = false)
&& $adapter::isMeetingRequirements()
) {
if ($prepend) {
self::$_adapters = array_merge(array($adapter), self::$_adapters);
self::$_adapters = array_merge(
array($adapter), self::$_adapters
);
} else {
self::$_adapters[] = $adapter;
}
Expand All @@ -96,6 +98,23 @@ public static function registerAdapter($adapter, $prepend = false)
return false;
}

/**
* Adds a value to the shared memory storage.
*
* Adds a value to the storage if it doesn't exist, or fails if it does.
*
* @param string $key Name of key to associate the value with.
* @param mixed $value Value for the specified key.
* @param int $ttl Seconds to store the value. If set to 0 indicates no
* time limit.
*
* @return bool TRUE on success, FALSE on failure.
*/
public function __invoke($key, $value, $ttl = 0)
{
return $this->add($key, $value, $ttl);
}

/**
* Gets a value from the shared memory storage.
*
Expand Down
2 changes: 1 addition & 1 deletion stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if ($isHttp) {
header('Content-Type: text/plain;charset=UTF-8');
}
echo "PEAR2_Cache_SHM @PACKAGE_VERSION@\n";
echo "@PACKAGE_NAME@ @PACKAGE_VERSION@\n";

if (version_compare(phpversion(), '5.3.0', '<')) {
echo "\nThis package requires PHP 5.3.0 or later.";
Expand Down

0 comments on commit 92a7d1a

Please sign in to comment.