PluginProbe
Embed Privacy / 1.11.2
Embed Privacy v1.11.2
1.14.0 1.13.0 trunk 0.1 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.10.0 1.10.1 1.10.10 1.10.2 1.10.3 1.10.4 1.10.5 1.10.6 1.10.7 1.10.8 1.10.9 1.11.0 1.11.1 1.11.2 All 68 releases
embed-privacy / inc / data / class-embed-cache.php

class-embed-cache.php in Embed Privacy 1.11.2, at inc/data/class-embed-cache.php

44 lines 904 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace epiphyt\Embed_Privacy\data;
3
4 /**
5 * Embed cache related functionality.
6 *
7 * @author Epiphyt
8 * @license GPL2
9 * @package epiphyt\Embed_Privacy
10 * @since 1.11.0
11 */
12 final class Embed_Cache {
13 /**
14 * Get an embed cache entry.
15 *
16 * @param string $url Embed URL
17 * @return mixed Embed cache entry
18 */
19 public static function get( $url ) {
20 return \get_transient( self::get_key( $url ) );
21 }
22
23 /**
24 * Get an embed cache key.
25 *
26 * @param string $url Embed URL
27 * @return string Embed cache key
28 */
29 public static function get_key( $url ) {
30 return 'embed_privacy_embed_' . \md5( $url );
31 }
32
33 /**
34 * Set an embed cache entry.
35 *
36 * @param string $url Embed URL
37 * @param mixed $data Data to cache
38 * @return bool Whether the value was set
39 */
40 public static function set( $url, $data ) {
41 return \set_transient( self::get_key( $url ), $data, \WEEK_IN_SECONDS );
42 }
43 }
44