ministryofjustice/aws-secrets-cache-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-08-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固