- Timestamp:
- 06/25/2026 09:08:14 AM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ai-client/adapters/class-wp-ai-client-cache.php
r62255 r62557 31 31 32 32 /** 33 * Retrieves the cache group used for cache operations, applying a filter for customization. 34 * 35 * @since 7.1.0 36 * 37 * @return string Cache group name. 38 */ 39 private function get_cache_group(): string { 40 /** 41 * Filters the cache group used by the WP AI Client cache adapter. 42 * 43 * Allows integrators to change the object cache group under which AI client 44 * items are stored. This is useful for avoiding key collisions, creating 45 * environment-specific caches, or adapting to backend constraints. 46 * 47 * @since 7.1.0 48 * 49 * @param string $group The cache group. 50 */ 51 return (string) apply_filters( 'wp_ai_client_cache_group', self::CACHE_GROUP ); 52 } 53 54 /** 33 55 * Fetches a value from the cache. 34 56 * … … 41 63 public function get( $key, $default_value = null ) { 42 64 $found = false; 43 $value = wp_cache_get( $key, self::CACHE_GROUP, false, $found );65 $value = wp_cache_get( $key, $this->get_cache_group(), false, $found ); 44 66 45 67 if ( ! $found ) { … … 63 85 $expire = $this->ttl_to_seconds( $ttl ); 64 86 65 return wp_cache_set( $key, $value, self::CACHE_GROUP, $expire );87 return wp_cache_set( $key, $value, $this->get_cache_group(), $expire ); 66 88 } 67 89 … … 75 97 */ 76 98 public function delete( $key ): bool { 77 return wp_cache_delete( $key, self::CACHE_GROUP);99 return wp_cache_delete( $key, $this->get_cache_group() ); 78 100 } 79 101 … … 93 115 } 94 116 95 return wp_cache_flush_group( self::CACHE_GROUP);117 return wp_cache_flush_group( $this->get_cache_group() ); 96 118 } 97 119 … … 112 134 */ 113 135 $keys_array = $this->iterable_to_array( $keys ); 114 $values = wp_cache_get_multiple( $keys_array, self::CACHE_GROUP);136 $values = wp_cache_get_multiple( $keys_array, $this->get_cache_group() ); 115 137 $result = array(); 116 138 … … 139 161 $values_array = $this->iterable_to_array( $values ); 140 162 $expire = $this->ttl_to_seconds( $ttl ); 141 $results = wp_cache_set_multiple( $values_array, self::CACHE_GROUP, $expire );163 $results = wp_cache_set_multiple( $values_array, $this->get_cache_group(), $expire ); 142 164 143 165 // Return true only if all operations succeeded. … … 155 177 public function deleteMultiple( $keys ): bool { 156 178 $keys_array = $this->iterable_to_array( $keys ); 157 $results = wp_cache_delete_multiple( $keys_array, self::CACHE_GROUP);179 $results = wp_cache_delete_multiple( $keys_array, $this->get_cache_group() ); 158 180 159 181 // Return true only if all operations succeeded. … … 171 193 public function has( $key ): bool { 172 194 $found = false; 173 wp_cache_get( $key, self::CACHE_GROUP, false, $found );195 wp_cache_get( $key, $this->get_cache_group(), false, $found ); 174 196 175 197 return (bool) $found;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)