|
2 | 2 |
|
3 | 3 | return [ |
4 | 4 | 'throttle' => [ |
| 5 | + // Option 1: Global enable/disable toggle |
| 6 | + // Set to false to disable throttling completely (useful for performance testing) |
| 7 | + // Default: true (enabled) |
| 8 | + // Example: THROTTLE_ENABLED=false |
| 9 | + 'enabled' => env('THROTTLE_ENABLED', true), |
| 10 | + |
| 11 | + // Maximum number of requests allowed per decay period |
| 12 | + // Default: 120 requests per minute |
| 13 | + // Example: THROTTLE_REQUESTS_PER_MINUTE=120 |
5 | 14 | 'max_attempts' => env('THROTTLE_REQUESTS_PER_MINUTE', 120), |
| 15 | + |
| 16 | + // Time window in minutes for throttle decay |
| 17 | + // Default: 1 minute |
| 18 | + // Example: THROTTLE_DECAY_MINUTES=1 |
6 | 19 | 'decay_minutes' => env('THROTTLE_DECAY_MINUTES', 1), |
| 20 | + |
| 21 | + // Option 3: Unlimited API keys (for production testing) |
| 22 | + // Comma-separated list of API keys that bypass throttling |
| 23 | + // These keys can be used for performance testing in production |
| 24 | + // Example: THROTTLE_UNLIMITED_API_KEYS=Bearer test_key_123,Bearer load_test_456 |
| 25 | + 'unlimited_keys' => array_filter(explode(',', env('THROTTLE_UNLIMITED_API_KEYS', ''))), |
| 26 | + ], |
| 27 | + |
| 28 | + 'cache' => [ |
| 29 | + // Enable/disable API model caching |
| 30 | + // Caching is enabled by default when HasApiModelCache trait is used |
| 31 | + // Set to false to disable caching globally |
| 32 | + // Default: true (enabled) |
| 33 | + // Example: API_CACHE_ENABLED=false |
| 34 | + 'enabled' => env('API_CACHE_ENABLED', true), |
| 35 | + |
| 36 | + // Cache TTL (Time To Live) in seconds |
| 37 | + 'ttl' => [ |
| 38 | + // Query result caching (list endpoints) |
| 39 | + // Default: 300 seconds (5 minutes) |
| 40 | + // Example: API_CACHE_QUERY_TTL=300 |
| 41 | + 'query' => env('API_CACHE_QUERY_TTL', 300), |
| 42 | + |
| 43 | + // Model instance caching (single record endpoints) |
| 44 | + // Default: 3600 seconds (1 hour) |
| 45 | + // Example: API_CACHE_MODEL_TTL=3600 |
| 46 | + 'model' => env('API_CACHE_MODEL_TTL', 3600), |
| 47 | + |
| 48 | + // Relationship caching |
| 49 | + // Default: 1800 seconds (30 minutes) |
| 50 | + // Example: API_CACHE_RELATIONSHIP_TTL=1800 |
| 51 | + 'relationship' => env('API_CACHE_RELATIONSHIP_TTL', 1800), |
| 52 | + ], |
| 53 | + |
| 54 | + // Cache driver (uses Laravel's cache configuration) |
| 55 | + // Options: redis, memcached, database, file |
| 56 | + // Default: uses config('cache.default') |
| 57 | + 'driver' => env('API_CACHE_DRIVER', config('cache.default')), |
| 58 | + |
| 59 | + // Cache key prefix |
| 60 | + // Default: 'fleetbase_api' |
| 61 | + 'prefix' => env('API_CACHE_PREFIX', 'fleetbase_api'), |
| 62 | + |
| 63 | + // Debug mode - adds X-Cache-Key header to responses |
| 64 | + // Default: false (only enabled when APP_DEBUG=true) |
| 65 | + 'debug' => env('API_CACHE_DEBUG', false), |
7 | 66 | ], |
8 | 67 | ]; |
0 commit comments