承接 ropi/in-memory-cache 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ropi/in-memory-cache

Composer 安装命令:

composer require ropi/in-memory-cache

包简介

PSR-16 compatible in-memory cache library

README 文档

README

This PHP-based library provides different in-memory caches.

Requirements

  • PHP ^8.0

Installation

The library can be installed from a command line interface by using composer.

composer require ropi/in-memory-cache

First In – First Out (FIFO)

<?php
$cache = new \Ropi\InMemoryCache\FifoInMemoryCache(defaultTtl: null, maxSize: 3);

$cache->set('a', 10);
$cache->set('b', 20);
$cache->set('c', 30);

var_dump($cache->get('b')); // Prints 20 
var_dump($cache->count()); // Prints 3

$cache->set('d', 40);

var_dump($cache->count()); // Still prints 3, because cache size is limited to 3 and thus first cache entry was deleted
var_dump($cache->get('a')); // Prints NULL, because 'a' was the first cache entry
var_dump($cache->get('d')); // Prints 40

Fixed sized

<?php
$cache = new \Ropi\InMemoryCache\FixedSizedInMemoryCache(defaultTtl: null, maxSize: 3);

$cache->set('a', 10);
$cache->set('b', 20);
$cache->set('c', 30);

var_dump($cache->get('b')); // Prints 20 
var_dump($cache->count()); // Prints 3

$cache->set('d', 40); // Throws OverflowException, because cache size is limited to 3

Time-to-live (TTL)

<?php
$cache = new \Ropi\InMemoryCache\InMemoryCache(defaultTtl: 2);

$cache->set('a', 10);

var_dump($cache->get('a')); // Prints 10 

sleep(3);

var_dump($cache->get('a')); // Prints NULL, because TTL expired

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固