Download the PHP package mustafa3264/lrucache without Composer

On this page you can find all versions of the php package mustafa3264/lrucache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lrucache

hyperf lrucache

基于swoole hyperf框架开发的,支持从 数据库 - redis - swoole table 三级缓存,支持给数据设置过期时间。

swoole table 通过lru淘汰算法清理早期插入的数据,通过限制swoole table的数据量,控制本地内存缓存使用量。

redis缓存使用 hash+zset 的组合存储数据,支持根据过期时间自动清理数据。

redis缓存更新通过监听数据库的修改和删除事件完成,在多实例swoole table缓存的更新则依赖redis的pub/sub机制

插件提供对swoole table的使用进行监控,以及lrucache 三级缓存的命中情况的监控

监控

接入

安装

配置

配置文件如下

使用

在hyperf启动时创建swoole table,因此需要在代码中定义好swoole table的字段、表名、最大容量(最大容量只能是2的N次方)、lru淘汰算法的触发数量,示例代码如下

RoleDaoImpl 是基于 hyperf规则,针对 数据库 role 映射出来的 ORM 模型,lrucache针对这个模型,有如下额外要求:

  1. 类名上有例如 @property string $name 这样的 php doc注释,这样 swoole table 可以根据这些创建表字段
  2. 类名上面有 #[SwooleTable(swooleTableSize: 8, lruLimit: 5, hashKeyLength: -1)] 这样的注解,swooleTableSize 是 swoole table 表创建时指定的最大size, lruLimit 时lru淘汰算法控制的链表最大长度,hashKeyLength 是对缓存key切割成hash的长度,-1 代表所有的缓存key共用一个hash
  3. 带有 SwooleTableCache 注解的 getById 函数,根据主键查询,返回模型的对象。使用该注解的查询会通过swoole table - redis - db 的顺序进行数据寻找。注解有 expire 参数,代码缓存设置的过期时间,没有配置该项,表明使用config配置的通用过期时间,也就是上面设置的一天。

进阶玩法

可以手动操作缓存

直接操作 swoole table + redis 缓存

存入数据,字段为前缀,key,数据数组,过期时间,会把数据放入lru算法的swoole table,以及 hash+zset 的 redis中

读取数据,如果swoole table没有数据,会从redis缓存拿,会校验数据是否过期

直接操作redis缓存

不想使用swoole table缓存?框架支持只把数据缓存到redis,不做swoole table的缓存,方法如下

联系作者

我的邮箱

微信

fanghailiang2023


All versions of lrucache with dependencies

PHP Build Version
Package Version
Requires ext-swoole Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mustafa3264/lrucache contains the following files

Loading the files please wait ....