PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / trunk
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution vtrunk
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Preload / Monitor / Repository.php

Repository.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution trunk, at src/Performance/Preload/Monitor/Repository.php

57 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The preload monitor repository to store the status.
4 *
5 * @package SolidWP\Performance
6 */
7
8 declare( strict_types=1 );
9
10 namespace SolidWP\Performance\Preload\Monitor;
11
12 /**
13 * The preload monitor repository to store the status.
14 *
15 * @package SolidWP\Performance
16 */
17 final class Repository {
18
19 public const OPTION = 'swpsp_preload_monitor';
20
21 /**
22 * Get preloader monitor status.
23 *
24 * @return array{count: int, last_activity: int, retries: int}
25 */
26 public function get(): array {
27 return (array) get_option( self::OPTION, [] );
28 }
29
30 /**
31 * Set the current URL count, current time and retries to compare to later.
32 *
33 * @param int $url_count The current URL count.
34 * @param int $retries The incremented retries.
35 *
36 * @return bool
37 */
38 public function set( int $url_count, int $retries = 0 ): bool {
39 $status = [
40 'count' => $url_count,
41 'last_activity' => time(),
42 'retries' => $retries,
43 ];
44
45 return update_option( self::OPTION, $status, false );
46 }
47
48 /**
49 * Delete the monitor data.
50 *
51 * @return bool
52 */
53 public function delete(): bool {
54 return delete_option( self::OPTION );
55 }
56 }
57