Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| Transient_Store | |
0.00% |
0 / 7 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 1 |
| cache_get | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| cache_set | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| cache_delete | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| cache_keys | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Transient Store. |
| 4 | * |
| 5 | * @package VideoPressUploader |
| 6 | **/ |
| 7 | |
| 8 | namespace VideoPressUploader; |
| 9 | |
| 10 | // Avoid direct calls to this file. |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | die( 0 ); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Transient - based store. |
| 17 | */ |
| 18 | class Transient_Store extends Tus_Abstract_Cache { |
| 19 | |
| 20 | /** |
| 21 | * Get key. |
| 22 | * |
| 23 | * @param string $key The blog_id. |
| 24 | * |
| 25 | * @return mixed|null |
| 26 | */ |
| 27 | public function cache_get( $key ) { |
| 28 | $contents = get_transient( $key ); |
| 29 | return empty( $contents ) ? null : $contents; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Set cache key. |
| 34 | * |
| 35 | * @param string $key The key. |
| 36 | * @param array|mixed $value Even get the expired key. |
| 37 | * @param bool $is_update Is this an update. |
| 38 | * |
| 39 | * @return bool |
| 40 | */ |
| 41 | public function cache_set( $key, $value, $is_update = false ) { |
| 42 | if ( $is_update ) { |
| 43 | delete_transient( $key ); |
| 44 | } |
| 45 | return set_transient( $key, $value, $this->get_ttl() ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Deletes a key. |
| 50 | * |
| 51 | * @param string $key The key. |
| 52 | * |
| 53 | * @return mixed |
| 54 | */ |
| 55 | public function cache_delete( $key ) { |
| 56 | return delete_transient( $key ); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Get cache keys. |
| 61 | * |
| 62 | * @param string $prefix Prefix. |
| 63 | * |
| 64 | * @return mixed |
| 65 | */ |
| 66 | public function cache_keys( $prefix ) { |
| 67 | return get_transient( $prefix ); |
| 68 | } |
| 69 | } |