/** * Test if a cache has at least one of the given keys. * * It is strongly recommended to avoid the use of this function if not absolutely required. * In a high load environment the cache may well change between the test and any subsequent action (get, set, delete etc). * * Its also worth mentioning that not all stores support key tests. * For stores that don't support key tests this functionality is mimicked by using the equivalent get method. * Just one more reason you should not use these methods unless you have a very good reason to do so. * * @param array $keys * @return bool True if the cache has at least one of the given keys */ public function has_any(array $keys) { if ($this->has_a_ttl() && !$this->store_supports_native_ttl() || !$this->store_supports_key_awareness()) { foreach ($keys as $key) { if ($this->has($key)) { return true; } } return false; } if ($this->use_static_acceleration()) { foreach ($keys as $id => $key) { if ($this->static_acceleration_has($key)) { return true; } } } $parsedkeys = array_map(array($this, 'parse_key'), $keys); return $this->store->has_any($parsedkeys); }
/** * Test if a cache has at least one of the given keys. * * It is strongly recommended to avoid the use of this function if not absolutely required. * In a high load environment the cache may well change between the test and any subsequent action (get, set, delete etc). * * Its also worth mentioning that not all stores support key tests. * For stores that don't support key tests this functionality is mimicked by using the equivalent get method. * Just one more reason you should not use these methods unless you have a very good reason to do so. * * @param array $keys * @return bool True if the cache has at least one of the given keys */ public function has_any(array $keys) { if ($this->has_a_ttl() && !$this->store_supports_native_ttl() || !$this->store_supports_key_awareness()) { foreach ($keys as $key) { if ($this->has($key)) { return true; } } return false; } if ($this->is_using_persist_cache()) { $parsedkeys = array(); foreach ($keys as $id => $key) { $parsedkey = $this->parse_key($key); if ($this->is_in_persist_cache($parsedkey)) { return true; } $parsedkeys[] = $parsedkey; } } else { $parsedkeys = array_map(array($this, 'parse_key'), $keys); } return $this->store->has_any($parsedkeys); }