PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.2
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
← All changes | includes/Utils/Database.php +32 -0 4.7.04.9.2 View file →
@@ -102,5 +102,37 @@
102 102
103 103 public function delete_transient( $transient ) {
104 104 return delete_transient( $transient );
105 105 }
106 +
107 + /**
108 + * Versioned-key incrementor. Reading the current version lets callers build
109 + * cache keys like "{namespace}_v{N}_..."; bumping the version makes every
110 + * key in that namespace unreachable in one update.
111 + *
112 + * The canonical value lives in wp_options so invalidation persists across
113 + * requests even on sites with no external object cache (where wp_cache_*
114 + * is per-request in-memory only). wp_cache_* is still used as a
115 + * within-request memoization layer.
116 + */
117 + public function get_cache_version( $namespace, $group = 'betterdocs' ) {
118 + $cache_key = $namespace . '_version';
119 + $option_key = 'bd_cache_v_' . $namespace;
120 + $v = wp_cache_get( $cache_key, $group );
121 + if ( false === $v ) {
122 + $v = (int) get_option( $option_key, 1 );
123 + if ( $v < 1 ) {
124 + $v = 1;
125 + }
126 + wp_cache_set( $cache_key, $v, $group, 0 );
127 + }
128 + return (int) $v;
129 + }
130 +
131 + public function bump_cache_version( $namespace, $group = 'betterdocs' ) {
132 + $cache_key = $namespace . '_version';
133 + $option_key = 'bd_cache_v_' . $namespace;
134 + $new = (int) get_option( $option_key, 1 ) + 1;
135 + update_option( $option_key, $new, false );
136 + wp_cache_set( $cache_key, $new, $group, 0 );
137 + }
106 138 }