ministryofjustice/aws-secrets-cache-php
Composer 安装命令:
composer require ministryofjustice/aws-secrets-cache-php
包简介
AWS Secrets Manager caching for PHP (PSR-16, APCu cache storage, ENV-prefixed secrets).
README 文档
README
Reusable helper class to fetch secrets at runtime from AWS Secrets Manager with a cache to reduce duplicate requests.
Requires a pre-configured cache implementing StorageInterface from laminas-cache.
Installation
composer require ministryofjustice/aws-secrets-cache-php
Usage
use Aws\SecretsManager\SecretsManagerClient; use Laminas\Cache\Storage\StorageInterface; use MoJ\AwsSecretsCache\AwsSecretsCache; $storage = /** instanceof StorageInterface */; $smClient = new SecretsManagerClient([...]); $secretsCache = new AwsSecretsCache(null, $storage, $smClient); $mySecret = $secretsCache->getValue('my-secret');
The first parameter optionally defines a namespace that will apply to all secrets retrieved by that instance of the class. The following example would return the secret named namespace/my-secret:
$secretsCache = new AwsSecretsCache('namespace', ...); $myNamespacedSecret = $secretsCache->getValue('my-secret');
You can use clearCache to remove an item from the underlying cache:
$mySecret = $secretsCache->getValue('my-secret'); $secretsCache->clearCache('my-secret'); $mySecret = $secretsCache->getValue('my-secret'); // Will fetch from AWS again
TTL must be implemented on the storage class, it is not applied by AwsSecretsCache.
统计信息
- 总下载量: 10.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-08-14