keinos/mastodon-streaming-api-cache

Simple Key-Value Store Class.

1.0.0 2020-07-20 13:44 UTC

This package is auto-updated.

Last update: 2024-11-22 22:04:25 UTC


README

Simple Key-Value Store Class for Caching

This is a simple Key-Value store PHP class for a simple purposes such as caching.

Install

composer require keinos/mastodon-streaming-api-cache

Usage

<?php

namespace KEINOS\Sample;

require_once __DIR__ . '/../vendor/autoload.php';

// Instantiate
use KEINOS\MSTDN_TOOLS\Cache\Cache;
$cache = new Cache();

// Set value to the cache
$key   = 'foo';
$value = 'bar';
$cache->set($key, $value);

// Get value from the cache
$actual = $cache->get($key);
$expect = $value;
echo ($expect === $actual) ? 'OK' : 'NG', PHP_EOL;

// Delete value from the cache
$result = $cache->delete($key);

// Clear all the caches
$result = $cache->clear();

Package Information