PHP code example of infinitypaul / idempotency-laravel
1. Go to this page and download the library: Download infinitypaul/idempotency-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
infinitypaul / idempotency-laravel example snippets
return [
// Enable or disable idempotency functionality
'enabled' => env('IDEMPOTENCY_ENABLED', true),
// HTTP methods that should be considered for idempotency
'methods' => ['POST', 'PUT', 'PATCH', 'DELETE'],
// How long to cache idempotent responses (in minutes)
'ttl' => env('IDEMPOTENCY_TTL', 1440), // 24 hours
// Validation settings
'validation' => [
// Pattern to validate idempotency keys (UUID format by default)
'pattern' => '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/',
// Maximum response size to cache (in bytes)
'max_length' => env('IDEMPOTENCY_MAX_LENGTH', 10485760), // 10MB
],
// Alert settings
'alert' => [
// Number of hits before sending an alert
'threshold' => env('IDEMPOTENCY_ALERT_THRESHOLD', 5),
],
// Telemetry settings
'telemetry' => [
// Default telemetry driver
'driver' => env('IDEMPOTENCY_TELEMETRY_DRIVER', 'inspector'),
// Custom driver class if using 'custom' driver
'custom_driver_class' => null,
],
];
namespace App\Telemetry;
use Infinitypaul\Idempotency\Telemetry\TelemetryDriver;
class CustomTelemetryDriver implements TelemetryDriver
{
// Implement the