PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.5
JetFormBuilder — Dynamic Blocks Form Builder v2.1.5
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 3 years ago exceptions 3 years ago models 3 years ago traits 3 years ago views 3 years ago base-db-constraint.php 3 years ago base-db-model.php 3 years ago execution-builder.php 3 years ago query-builder.php 3 years ago query-cache-builder.php 3 years ago query-conditions-builder.php 3 years ago
query-cache-builder.php
99 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Db_Queries;
5
6
7 use Jet_Form_Builder\Db_Queries\Views\View_Base;
8
9 /**
10 * @method Query_Cache_Builder set_view( View_Base $view )
11 *
12 * Class Query_Builder
13 * @package Jet_Form_Builder\Db_Queries
14 */
15 class Query_Cache_Builder extends Query_Builder {
16
17 const CACHE_GROUP = 'jfb_queries';
18 protected $hash;
19
20 /**
21 * @param string $prefix
22 *
23 * @return string
24 */
25 public function get_hash( $prefix = '' ) {
26 if ( ! empty( $this->hash ) ) {
27 return $this->hash;
28 }
29 $this->hash = $prefix . md5( $this->sql() );
30
31 return $this->hash;
32 }
33
34 /**
35 * @param string $prefix
36 *
37 * @return false|mixed
38 */
39 public function get_cached( $prefix = '' ) {
40 return wp_cache_get( $this->get_hash( $prefix ), self::CACHE_GROUP );
41 }
42
43 public function query_all(): array {
44 $cached = $this->get_cached( 'query_all_' );
45
46 if ( $cached !== false ) {
47 return $cached;
48 }
49
50 $results = parent::query_all();
51
52 wp_cache_set( $this->get_hash(), $results, self::CACHE_GROUP );
53
54 return $results;
55 }
56
57 public function query_one(): array {
58 $cached = $this->get_cached( 'query_one_' );
59
60 if ( $cached !== false ) {
61 return $cached;
62 }
63
64 $results = parent::query_one();
65
66 wp_cache_set( $this->get_hash(), $results, self::CACHE_GROUP );
67
68 return $results;
69 }
70
71 public function query_var( $column_offset = 0, $row_offset = 0 ) {
72 $cached = $this->get_cached( "query_var_{$column_offset}_{$row_offset}_" );
73
74 if ( $cached !== false ) {
75 return $cached;
76 }
77
78 $results = parent::query_var();
79
80 wp_cache_set( $this->get_hash(), $results, self::CACHE_GROUP );
81
82 return $results;
83 }
84
85 public function query_col( $index = 0 ) {
86 $cached = $this->get_cached( "query_col_{$index}_" );
87
88 if ( $cached !== false ) {
89 return $cached;
90 }
91
92 $results = parent::query_col( $index );
93
94 wp_cache_set( $this->get_hash(), $results, self::CACHE_GROUP );
95
96 return $results;
97 }
98
99 }