承接 peterpalma/file-cache 相关项目开发

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

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

peterpalma/file-cache

Composer 安装命令:

composer require peterpalma/file-cache

包简介

Stores cache on disk rather than in a database

README 文档

README

I had to do with a hosting company that just refused to enable memcache/memcached/redis because it wasn't a one-click install option in CPanel. So that's why I wrote this class as the storage drives are fast SSDs.

I'm including both a procedural version and a class version.

Tested on:

PHP 7.3 PHP 7.4 PHP 8.0 PHP 8.1 PHP 8.2

How is this different from memcache/memcached/redis

The main difference is that this stores the data in json files on the harddrive and when you fetch the data you specify how old the data is that you load rather than how old the data is until it expires when you save it as you do in a memory cache server as this doesn't contain a server software.

Procedural usage

Include the cache.php for the Procedural version such as:

<?php
require 'cache.php';

fileCacheGet($key, $ttl)

$key: String value for your cache key
$ttl: How old cache you can load specified as seconds, default 120 seconds

fileCacheSet($key, $data)

$key: String value for your cache key
$data: The data to store

fileCacheDelete($key)

$key: Deletes the cache file for this cache

Class usage

Install using composer

composer require palma/file-cache

Include the class_filecache.php for the Class version

<?php
require './vendor/autoload.php';
$cache = new FileCache();

$cache::get($key, $ttl)

$key: String value for your cache key
$ttl: How old cache you can load specified as seconds, default 120 seconds

$cache::set($key, $data)

$key: String value for your cache key
$data: The data to store

$cache::delete($key)

$key: Deletes the cache file for this cache

Author

Peter Palma

Donate to the project

Buy me a Pizza

License

MIT License, see included LICENSE file.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固