PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.3.1
JetFormBuilder — Dynamic Blocks Form Builder v3.3.1
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / db-queries / query-cache-builder.php
jetformbuilder / includes / db-queries Last commit date
constraints 2 years ago exceptions 2 years ago models 2 years ago traits 2 years ago views 2 years ago base-db-constraint.php 2 years ago base-db-model.php 2 years ago execution-builder.php 2 years ago query-builder.php 2 years ago query-cache-builder.php 2 years ago query-conditions-builder.php 2 years ago
query-cache-builder.php
104 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Db_Queries;
5
6 use Jet_Form_Builder\Db_Queries\Views\View_Base;
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 /**
14 * @method Query_Cache_Builder set_view( View_Base $view )
15 *
16 * Class Query_Builder
17 * @package Jet_Form_Builder\Db_Queries
18 */
19 class Query_Cache_Builder extends Query_Builder {
20
21 const CACHE_GROUP = 'jfb_queries';
22 protected $hash;
23
24 /**
25 * @param string $prefix
26 *
27 * @return string
28 */
29 public function get_hash( $prefix = '' ) {
30 if ( ! empty( $this->hash ) ) {
31 return $this->hash;
32 }
33 $this->hash = $prefix . md5( $this->sql() );
34
35 return $this->hash;
36 }
37
38 /**
39 * @param string $prefix
40 *
41 * @return false|mixed
42 */
43 public function get_cached( $prefix = '' ) {
44 return wp_cache_get( $this->get_hash( $prefix ), self::CACHE_GROUP );
45 }
46
47 public function query_all(): array {
48 $cached = $this->get_cached( 'query_all_' );
49
50 if ( false !== $cached ) {
51 return $cached;
52 }
53
54 $results = parent::query_all();
55
56 wp_cache_set( $this->get_hash(), $results, self::CACHE_GROUP );
57
58 return $results;
59 }
60
61 public function query_one(): array {
62 $cached = $this->get_cached( 'query_one_' );
63
64 if ( false !== $cached ) {
65 return $cached;
66 }
67
68 $results = parent::query_one();
69
70 wp_cache_set( $this->get_hash(), $results, self::CACHE_GROUP );
71
72 return $results;
73 }
74
75 public function query_var( $column_offset = 0, $row_offset = 0 ) {
76 $cached = $this->get_cached( "query_var_{$column_offset}_{$row_offset}_" );
77
78 if ( false !== $cached ) {
79 return $cached;
80 }
81
82 $results = parent::query_var();
83
84 wp_cache_set( $this->get_hash(), $results, self::CACHE_GROUP );
85
86 return $results;
87 }
88
89 public function query_col( $index = 0 ) {
90 $cached = $this->get_cached( "query_col_{$index}_" );
91
92 if ( false !== $cached ) {
93 return $cached;
94 }
95
96 $results = parent::query_col( $index );
97
98 wp_cache_set( $this->get_hash(), $results, self::CACHE_GROUP );
99
100 return $results;
101 }
102
103 }
104