Meza/caching
< Meza
See Cache: audit and review the caching in Meza #111
The following was AI generated and should be marked as verified after review
Semantic MediaWiki Additional Caching Mechanisms edit
Semantic MediaWiki (SMW) adds several specialized caching layers beyond standard MediaWiki caching.
SMW-Specific Cache Types edit
Query Result Cache edit
- Purpose: Caches results of
#askqueries and concept queries - Configuration:
$smwgQueryResultCacheTypeand$smwgQueryResultCacheLifetime - Default: Uses MediaWiki's main cache (
CACHE_ANYTHING) - Storage: Separate from page cache, stores semantic query results
Property Table Cache edit
- Purpose: Caches the mapping of properties to their database tables
- Key Variable:
$smwgPropertiesCache - Impact: Affects how SMW resolves which table contains property values
- Invalidation: Triggered on property type changes or new properties
Concept Cache edit
- Purpose: Pre-computed query results for
[[Category:Concepts]] - Configuration:
$smwgAutoRefreshSubjectcontrols auto-refresh - Mechanism: Runs concept queries in background, stores results
- Manual Refresh:
php maintenance/SMW_refreshData.php -page "Concept:Name"
Dependency Cache edit
- Purpose: Tracks dependencies between pages with semantic data
- Function: Ensures pages using
#askqueries update when source data changes - Integration: Works with MediaWiki's
LinksUpdatesystem - Performance: Can cause cascading updates on heavily-queried wikis
Statistical Cache edit
- Purpose: Caches statistics about semantic data (property usage counts, etc.)
- Location: Special:Statistics and Special:Properties pages
- Configuration:
$smwgStatisticsCacheand$smwgStatisticsRefreshInterval
Serializer Cache edit
- Purpose: Caches serialized semantic data objects (DIWikiPage, DIProperty)
- Type: Object-level caching for frequently accessed semantic entities
- Benefit: Reduces database queries for property metadata
Key Differences from Standard MediaWiki Caching edit
| Aspect | MediaWiki | Semantic MediaWiki |
|---|---|---|
| Parser Cache | Caches rendered HTML | Also stores embedded query metadata |
| Link Tables | Simple page-to-page links | Complex property-value relationships |
| Cache Invalidation | On page edit | On edit + when queried data changes |
| Database Load | Primarily page text | + semantic property tables (20+ tables) |
Configuration in Meza Context edit
In /opt/conf-meza/public/<env>/LocalSettings.php or extension configs:
// Query result caching
$smwgQueryResultCacheType = CACHE_MEMCACHED; // or CACHE_REDIS
$smwgQueryResultCacheLifetime = 3600; // seconds
// Enable query dependency tracking
$smwgEnabledQueryDependencyLinksStore = true;
// Concept cache refresh
$smwgAutoRefreshSubject = true; // Auto-refresh concepts on editPerformance Implications edit
High-Impact Scenarios edit
- Inline Queries: Pages with many
{{#ask:}}queries benefit most from query cache - Concepts: Pre-cached concepts avoid expensive runtime queries
- Property Pages: Heavily accessed properties (like
[[Has type::Page]]) benefit from property cache
Cache Warming Strategies edit
# Rebuild semantic data cache
php maintenance/SMW_refreshData.php -d 50 -v
# Refresh specific namespace
php maintenance/SMW_refreshData.php -page "Property:*" -v
# Force rebuild with full delete
php maintenance/SMW_refreshData.php -d 50 -v -fDebugging SMW Cache Issues edit
# Check SMW cache status
php maintenance/SMW_debugCaches.php
# Clear SMW query cache
php maintenance/SMW_clearQueryCache.php
# View cache backend
grep smwgQueryResultCacheType /opt/conf-meza/public/<env>/LocalSettings.phpIntegration with Meza's Caching edit
Meza's MediaWiki role configures:
- Memcached/Redis: Backend for
$smwgQueryResultCacheType - Parser Cache: Shared cache for rendered pages with SMW queries
- Database Query Cache: MySQL query cache affects property table reads
The mediawiki role in Meza handles SMW cache configuration through templates in src/roles/mediawiki/templates/, particularly in the extension-specific configuration files.