1 <?php 2 /* Copyright (c) 2012, Geert Bergman (geert@scrivo.nl) 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 3. Neither the name of "Scrivo" nor the names of its contributors may be 14 * used to endorse or promote products derived from this software without 15 * specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * POSSIBILITY OF SUCH DAMAGE. 28 * 29 * $Id: NoCache.php 629 2013-05-20 23:02:09Z geert $ 30 */ 31 32 /** 33 * Implementation of the \Scrivo\NoCache class. 34 */ 35 36 namespace Scrivo\Cache; 37 38 /** 39 * No-cache implementation of the Cache interface. 40 * 41 * This is an implementation of the Cache interface that you can use when 42 * you don't want any caching to take place. No data will be stored and 43 * null is returned on all fetches. 44 */ 45 class NoCache implements \Scrivo\Cache { 46 47 /** 48 * Create an APC cache wrapper. 49 */ 50 public function __construct() { 51 } 52 53 /** 54 * Pretend to store a variable in the cache. 55 * 56 * @param \Scrivo\String $key A cache unique name for the key. 57 * @param mixed $val The (serializable) variabele to strore. 58 * @param int $ttl Time to live in seconds. 59 * 60 * @return int DATA_STORED although no data will be stored. 61 * 62 * @throws \Scrivo\SystemException When trying to store a NULL value. 63 */ 64 public function store(\Scrivo\String $key, $val, $ttl=3600) { 65 if ($val === null) { 66 throw new \Scrivo\SystemException( 67 "Can't store null values in the cache"); 68 } 69 return self::DATA_STORED; 70 } 71 72 /** 73 * Pretend to overwrite a variable in the cache. 74 * 75 * @param \Scrivo\String $key A cache unique name for the key. 76 * @param mixed $val The (serializable) variabele to strore. 77 * @param int $ttl Time to live in seconds. 78 * 79 * @return int DATA_STORED although no data will be stored. 80 * 81 * @throws \Scrivo\SystemException When trying to store a NULL value. 82 */ 83 public function overwrite(\Scrivo\String $key, $val, $ttl=3600) { 84 if ($val === null) { 85 throw new \Scrivo\SystemException( 86 "Can't store null values in the cache"); 87 } 88 return self::DATA_STORED; 89 } 90 91 /** 92 * Pretend to delete/remove a cache entry. 93 * 94 * @param \Scrivo\String $key A cache unique name for the key. 95 */ 96 public function delete(\Scrivo\String $key) { 97 } 98 99 /** 100 * Perform a failed fetch from the cache. 101 * 102 * @param \Scrivo\String $key The key for which to retrieve the value. 103 * 104 * @return mixed The value of the stored variable or NULL if the key 105 * does not exists or is expired. 106 */ 107 public function fetch(\Scrivo\String $key) { 108 null; 109 } 110 111 /** 112 * List all (=none) entries in the cache. 113 * 114 * @return object[] An empty array. 115 */ 116 public function entryList() { 117 return array(); 118 } 119 120 } 121 122
Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013