Merge pull request #17345 from eileenmcnaughton/ev_batch
[civicrm-core.git] / CRM / Utils / Cache / Interface.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
7b5937fe 16 *
ebf0eb53
TO
17 * CRM_Utils_Cache_Interface is a long-standing interface used within CiviCRM
18 * for interacting with a cache service. In style and substance, it is extremely
19 * similar to PHP-FIG's SimpleCache interface (PSR-16). Consequently, beginning
20 * with CiviCRM v5.4, this extends \Psr\SimpleCache\CacheInterface.
7b5937fe 21 *
ebf0eb53 22 * @see https://www.php-fig.org/psr/psr-16/
6a488035 23 */
ebf0eb53 24interface CRM_Utils_Cache_Interface extends \Psr\SimpleCache\CacheInterface {
6a488035
TO
25
26 /**
fe482240 27 * Set the value in the cache.
6a488035
TO
28 *
29 * @param string $key
30 * @param mixed $value
858451a9
TO
31 * @param null|int|\DateInterval $ttl
32 * @return bool
6a488035 33 */
858451a9 34 public function set($key, $value, $ttl = NULL);
6a488035
TO
35
36 /**
fe482240 37 * Get a value from the cache.
6a488035
TO
38 *
39 * @param string $key
2da67cc5 40 * @param mixed $default
72b3a70c 41 * @return mixed
2da67cc5 42 * The previously set value value, or $default (NULL).
6a488035 43 */
2da67cc5 44 public function get($key, $default = NULL);
6a488035
TO
45
46 /**
fe482240 47 * Delete a value from the cache.
6a488035
TO
48 *
49 * @param string $key
eec321a4 50 * @return bool
6a488035 51 */
00be9182 52 public function delete($key);
6a488035
TO
53
54 /**
fe482240 55 * Delete all values from the cache.
124e5288 56 *
c31de879
TO
57 * NOTE: flush() and clear() should be aliases. flush() is specified by
58 * Civi's traditional interface, and clear() is specified by PSR-16.
59 *
124e5288 60 * @return bool
c31de879
TO
61 * @see clear
62 * @deprecated
6a488035 63 */
00be9182 64 public function flush();
96025800 65
c31de879
TO
66 /**
67 * Delete all values from the cache.
68 *
69 * NOTE: flush() and clear() should be aliases. flush() is specified by
70 * Civi's traditional interface, and clear() is specified by PSR-16.
71 *
72 * @return bool
73 * @see flush
74 */
75 public function clear();
76
9f70b0e4
TO
77 /**
78 * Determines whether an item is present in the cache.
79 *
80 * NOTE: It is recommended that has() is only to be used for cache warming type purposes
81 * and not to be used within your live applications operations for get/set, as this method
82 * is subject to a race condition where your has() will return true and immediately after,
83 * another script can remove it making the state of your app out of date.
84 *
85 * @param string $key The cache item key.
86 *
87 * @return bool
88 */
89 public function has($key);
90
6a488035 91}