PluginProbe
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation / trunk
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation vtrunk
1.4.48 1.4.47 1.4.46 1.4.45 1.4.44 1.4.43 1.4.42 1.4.41 1.4.40 1.4.39 1.4.38 1.4.37 1.4.36 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 64 releases
optin / includes / utils / class-cache.php

class-cache.php in WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation trunk, at includes/utils/class-cache.php

51 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore
2
3 namespace OPTN\Includes\Utils;
4
5 use OPTN\Includes\Traits\Singleton;
6
7 defined( 'ABSPATH' ) || exit;
8
9
10 /**
11 * Cache class
12 */
13 class Cache {
14 use Singleton;
15
16 /**
17 * Gets value from cache by key
18 *
19 * @param string $key key of the value.
20 * @param mixed $default_value default value if value in not in cache.
21 * @return mixed
22 */
23 public static function get( $key, $default_value = null ) {
24 $res = get_transient( $key );
25 return $res ? $res : $default_value;
26 }
27
28 /**
29 * Deletes value from cache by kea
30 *
31 * @param string $key key of the value.
32 * @return bool
33 */
34 public static function remove( $key ) {
35 return delete_transient( $key );
36 }
37
38 /**
39 * Sets a value in cache
40 *
41 * @param string $key key of the value.
42 * @param mixed $value value to store in cache.
43 * @param int|null $days cache expiration in days.
44 * @return bool
45 */
46 public static function set( $key, $value, $days = null ) {
47 $d = empty( $days ) ? OPTN_CACHE_DAY : $days;
48 return set_transient( $key, $value, DAY_IN_SECONDS * $d );
49 }
50 }
51