feat: implement repository architecture with smart caching
- Add base repository interfaces and abstract classes - Implement separated read/write repositories for Domain and Username models - Add intelligent query caching with automatic invalidation - Include cache management service and CLI commands - Add comprehensive configuration for cache TTL and monitoring - Enhance performance through optimized data access patterns
This commit is contained in:
188
config/repositories.php
Normal file
188
config/repositories.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Repository Cache Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file contains configuration options for the repository caching system.
|
||||
| You can customize TTL values, enable/disable caching, and configure
|
||||
| cache tags for different repository types.
|
||||
|
|
||||
*/
|
||||
|
||||
'cache' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache TTL (seconds)
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Default time-to-live for cached repository results. Can be overridden
|
||||
| per repository or per method call.
|
||||
|
|
||||
*/
|
||||
'default_ttl' => env('REPOSITORY_CACHE_TTL', 3600), // 1 hour
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable Caching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Global switch to enable/disable repository caching. Useful for
|
||||
| debugging environments.
|
||||
|
|
||||
*/
|
||||
'enabled' => env('REPOSITORY_CACHE_ENABLED', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Prefix to use for all repository cache keys.
|
||||
|
|
||||
*/
|
||||
'prefix' => env('REPOSITORY_CACHE_PREFIX', 'repo'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Repository-specific TTL Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You can configure different TTL values for different repositories
|
||||
| or specific methods.
|
||||
|
|
||||
*/
|
||||
'ttl' => [
|
||||
'domains' => [
|
||||
'default' => 3600, // 1 hour
|
||||
'active' => 1800, // 30 minutes
|
||||
'count' => 600, // 10 minutes
|
||||
'expiring_soon' => 900, // 15 minutes
|
||||
'recently_used' => 900, // 15 minutes
|
||||
],
|
||||
'usernames' => [
|
||||
'default' => 3600, // 1 hour
|
||||
'active' => 1800, // 30 minutes
|
||||
'count' => 600, // 10 minutes
|
||||
'expiring_soon' => 900, // 15 minutes
|
||||
'recently_used' => 900, // 15 minutes
|
||||
'available_for_use' => 300, // 5 minutes
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Tags
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Tags used for cache invalidation. Each repository should have its
|
||||
| own tag to ensure selective cache clearing.
|
||||
|
|
||||
*/
|
||||
'tags' => [
|
||||
'domains' => 'domains',
|
||||
'usernames' => 'usernames',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Warming
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configuration for warming up cache with frequently accessed data.
|
||||
|
|
||||
*/
|
||||
'warming' => [
|
||||
'enabled' => env('REPOSITORY_CACHE_WARMING_ENABLED', false),
|
||||
'commands' => [
|
||||
'domains:active',
|
||||
'usernames:active',
|
||||
'domains:count',
|
||||
'usernames:count',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Repository Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| General repository configuration options.
|
||||
|
|
||||
*/
|
||||
'repositories' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Page Size
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Default number of items per page for pagination.
|
||||
|
|
||||
*/
|
||||
'default_page_size' => 15,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Max Page Size
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Maximum number of items allowed per page to prevent excessive
|
||||
| memory usage.
|
||||
|
|
||||
*/
|
||||
'max_page_size' => 100,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Transaction Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Timeout in seconds for repository transactions.
|
||||
|
|
||||
*/
|
||||
'transaction_timeout' => 30,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Performance Monitoring
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configuration for monitoring repository performance and cache hit rates.
|
||||
|
|
||||
*/
|
||||
'monitoring' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable Performance Monitoring
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Track query execution times and cache hit rates.
|
||||
|
|
||||
*/
|
||||
'enabled' => env('REPOSITORY_MONITORING_ENABLED', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Slow Queries
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Log queries that take longer than this many milliseconds.
|
||||
|
|
||||
*/
|
||||
'slow_query_threshold' => 1000, // 1 second
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Cache Misses
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Log cache misses for debugging purposes.
|
||||
|
|
||||
*/
|
||||
'log_cache_misses' => env('REPOSITORY_LOG_CACHE_MISSES', false),
|
||||
],
|
||||
];
|
||||
Reference in New Issue
Block a user