This document covers the data handling utilities and caching mechanisms used throughout the Multisite Language Switcher plugin. These components provide efficient data storage, retrieval, and manipulation capabilities for language relationships, SQL query results, and structured data containers.
For information about how options are stored and managed, see Options and Configuration Storage. For details on content type handling, see Content Type Management.
The plugin implements a comprehensive SQL caching layer through the MslsSqlCacher
class, which wraps WordPress database operations with object cache functionality.
The MslsSqlCacher
serves as a proxy for the WordPress $wpdb
object, automatically caching results from get_*
methods while allowing direct passthrough for modification operations.
Sources: includes/MslsSqlCacher.php1-108 includes/MslsOptionsQuery.php20-28
The caching system uses WordPress's object cache with a dedicated cache group msls-cache-group
. Cache keys are generated from the calling class and parameters to ensure uniqueness.
Component | Purpose | Cache Duration |
---|---|---|
MslsSqlCacher::create() | Factory for cache instances | Configurable expiration |
__call() magic method | Intercepts get_* database calls | Per-request or persistent |
CACHE_GROUP constant | Isolates plugin cache data | N/A |
The caching logic only applies to database read operations (get_var
, get_results
, etc.), allowing write operations to execute immediately without cache interference.
Sources: includes/MslsSqlCacher.php66-74 includes/MslsSqlCacher.php95-107
The MslsGetSet
class provides a foundation for dynamic property management with automatic cleanup of empty values.
Sources: includes/MslsGetSet.php12-116
The MslsLanguageArray
class manages validated language-to-ID mappings with strict input validation.
The validation ensures data integrity by:
Sources: includes/MslsLanguageArray.php23-46 includes/MslsLanguageArray.php56-75
The MslsJson
class structures data for JavaScript consumption in admin interfaces.
Sources: includes/MslsJson.php26-33 includes/MslsJson.php52-76
The various MslsOptionsQuery
subclasses demonstrate the caching system's integration:
Each query class provides parameters through get_params()
methods that become part of the cache key, ensuring proper cache isolation between different query contexts.
Sources: includes/MslsOptionsQuery.php44-64 includes/MslsOptionsQueryDay.php39-45
The MslsGetSet
foundation enables consistent property access across option classes:
Method | Usage Pattern | Example |
---|---|---|
has_value($key) | Check for non-empty values | Language link existence |
__get($key) | Direct property access | Retrieve post ID |
__set($key, $value) | Store with auto-cleanup | Set language relationships |
reset() | Clear all data | Reinitialize options |
Sources: includes/MslsGetSet.php95-97 includes/MslsGetSet.php25-31
Cache keys combine class names and parameters to prevent collisions while maintaining readability for debugging:
{ClassName}_{Parameters}
esc_attr()
The MslsGetSet
class automatically manages memory by:
__set()
The caching layer reduces database load by:
get_*
method resultsSources: includes/MslsSqlCacher.php66-74 includes/MslsGetSet.php67-75
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.