momentohq/momento-php-redis-client 问题修复 & 功能扩展

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

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

momentohq/momento-php-redis-client

最新稳定版本:v0.3.1

Composer 安装命令:

composer require momentohq/momento-php-redis-client

包简介

Momento drop-in replacement for phpredis: A seamless drop-in replacement for phpredis, built with the Momento SDK for PHP. It mirrors the phpredis interface while leveraging Momento’s serverless cache for effortless scalability and zero operational overhead.

README 文档

README

logo

project status project stability

Momento Drop-in Replacement for PhpRedis

Welcome to the Momento Drop-in Replacement for PhpRedis! This package is a wrapper around PhpRedis allowing for integration with Momento cache. You can use this as a direct replacement for PhpRedis, while leveraging the benefits of Momento serverless cache.

Usage

<?php
declare(strict_types=1);

use Momento\Auth\CredentialProvider;
use Momento\Cache\CacheClient;
use Momento\Cache\MomentoCacheClient;
use Momento\Config\Configurations\Laptop;
use Momento\Logging\StderrLoggerFactory;

require "vendor/autoload.php";

$CACHE_NAME = uniqid("php-example-");
$ITEM_DEFAULT_TTL_SECONDS = 60;
$KEY = uniqid("myKey-");
$VALUE = uniqid("myValue-");

// Create a Momento cache client
$authProvider = CredentialProvider::fromEnvironmentVariable("MOMENTO_API_KEY");
$configuration = Laptop::latest(new StderrLoggerFactory());
$client = new CacheClient($configuration, $authProvider, $ITEM_DEFAULT_TTL_SECONDS);
$logger = $configuration->getLoggerFactory()->getLogger("ex:");

// Create a Redis client backed by Momento cache client over the cache
$momentoCacheClient = new MomentoCacheClient($client, $CACHE_NAME);

// IMPORTANT: The example assumes that the cache ($CACHE_NAME) is already created.
// To create a cache, you can use the Momento Console (https://console.gomomento.com/) or SDK methods.
// Refer to the documentation (https://docs.momentohq.com/platform/sdks/php/cache) for details.

// Perform operations vs Momento as if using a regular Redis client
$setResult = $momentoCacheClient->set($KEY, $VALUE);
$logger->info("Set result: " . $setResult . "\n");

$getResult = $momentoCacheClient->get($KEY);
$logger->info("Get result: " . $getResult . "\n");

Getting Started and Documentation

To get started with the drop-in client, you will need a Momento API key. You can get one from the Momento Console.

Installation

The Momento Drop-in Replacement for Phpredis is available on packagist.org: momento-php-redis

Examples

Working example projects, with all required build configuration files, are available in the examples directory.

Developing

If you are interested in contributing to the SDK, please see the CONTRIBUTING docs.

Attributions

This product includes PHP software, freely available from http://www.php.net/software/

For more info, visit our website at https://gomomento.com!

统计信息

  • 总下载量: 855
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2024-10-25