From 92a7d1a33d342a1e33b57fb7c9751d5fe7e9cad5 Mon Sep 17 00:00:00 2001 From: Vasil Rangelov Date: Tue, 25 Sep 2012 23:15:10 +0300 Subject: [PATCH] Added SHM::__invoke() as a shortcut to SHM::add(); Minor fixes to the PHAR stub; Release notes. --- RELEASE-0.1.0 | 1 + RELEASE-0.1.1 | 4 ++++ package.xml | 12 ++++++++---- src/PEAR2/Cache/SHM.php | 21 ++++++++++++++++++++- stub.php | 2 +- 5 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 RELEASE-0.1.0 create mode 100644 RELEASE-0.1.1 diff --git a/RELEASE-0.1.0 b/RELEASE-0.1.0 new file mode 100644 index 0000000..fe1413d --- /dev/null +++ b/RELEASE-0.1.0 @@ -0,0 +1 @@ +First PEAR2 compatible release. \ No newline at end of file diff --git a/RELEASE-0.1.1 b/RELEASE-0.1.1 new file mode 100644 index 0000000..1f28e82 --- /dev/null +++ b/RELEASE-0.1.1 @@ -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(). \ No newline at end of file diff --git a/package.xml b/package.xml index 00ec7a2..e5f69fa 100644 --- a/package.xml +++ b/package.xml @@ -11,10 +11,10 @@ boen.robot@gmail.com yes - 2012-08-03 - + 2012-09-25 + - 0.1.0 + 0.1.1 0.1.0 @@ -22,10 +22,14 @@ alpha LGPL License 2.1 - First PEAR2 compatible release. + * 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(). + diff --git a/src/PEAR2/Cache/SHM.php b/src/PEAR2/Cache/SHM.php index c0bec14..7616210 100644 --- a/src/PEAR2/Cache/SHM.php +++ b/src/PEAR2/Cache/SHM.php @@ -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; } @@ -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. * diff --git a/stub.php b/stub.php index adc2621..4062466 100644 --- a/stub.php +++ b/stub.php @@ -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.";