momentohq/client-sdk-php

PHP SDK for Momento, a serverless cache that automatically scales without any of the operational overhead required by traditional caching solutions.

v1.7.1 2024-03-06 21:54 UTC

This package is auto-updated.

Last update: 2024-04-13 20:18:53 UTC


README

logo

project status project stability

Momento PHP Client Library

Momento Cache is a fast, simple, pay-as-you-go caching solution without any of the operational overhead required by traditional caching solutions. This repo contains the source code for the Momento PHP client library.

To get started with Momento you will need a Momento Auth Token. You can get one from the Momento Console.

Japanese: 日本語

Packages

The Momento PHP SDK package is available on packagist.org: client-sdk-php

Usage

<?php
require "vendor/autoload.php";
use Momento\Auth\CredentialProvider;
use Momento\Cache\CacheClient;
use Momento\Config\Configurations\Laptop;

$client = new CacheClient(
    Laptop::latest(), CredentialProvider::fromEnvironmentVariable("MOMENTO_AUTH_TOKEN"), 60
);
$client->createCache("cache");
$client->set("cache", "myKey", "myValue");
$response = $client->get("cache", "myKey");
if ($hit = $response->asHit()) {
    print("Got value: {$hit->valueString()}\n");
}

Getting Started and Documentation

To get started with Momento you will need a Momento Auth Token. You can get one from the Momento Console.

Documentation is available on the Momento Docs website.

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.

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