Download the PHP package esd/hashed-wheel-timer-plugin without Composer

On this page you can find all versions of the php package esd/hashed-wheel-timer-plugin. 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 hashed-wheel-timer-plugin

hashed-wheel-timer-plugin

HashedWheelTimer是采用一种定时轮的方式来管理和维护大量的Timer调度算法。 一个 HashedWheelTimer 是环形结构,类似一个时钟,分为很多槽,一个槽代表一个时间间隔,每个槽又对应一个类似Map结构的对象,使用双向链表存储定时任务,指针周期性的跳动,跳动到一个槽位,就执行该槽位的定时任务。 环形结构可以根据超时时间的 hash 值(这个 hash 值实际上就是ticks & mask)将 task 分布到不同的槽位中, 当 tick 到那个槽位时, 只需要遍历那个槽位的 task 即可知道哪些任务会超时(而使用线性结构, 你每次 tick 都需要遍历所有 task), 所以, 我们任务量大的时候, 相应的增加 wheel 的 ticksPerWheel 值, 可以减少 tick 时遍历任务的个数.

本插件模拟java HashedWheelTimer 的实现。使用redis做持久存储。

配置方法

配置一个环形结构池

hashedWheelTimer:
  db: default
  max_pending_timeouts: 100
  wheel:
    - {name: aaa, tick_duration: 1, ticks_per_wheel: 60 }

name 池子名称,投递任务的时候需要

tick_duration,时间间隔,1秒

ticks_per_wheel,时间槽数量,60个,代表一分钟一个轮次

max_pending_timeouts,每一个槽允许的最大协程数,默认100,如果耗时任务或者队列特别长需要适当增加时间槽数量比如3600。不适合特别精准的延时场景。

db,使用的 redis 配置,强烈建议不要使用default,会占用http服务的连接数,应该复制一份配置专用

使用方法

投递任务

  //环形池名称,执行任务的类,投递参数,延迟执行时间,秒
  $this->addTask('aaa', TimerTask::class,['a'=>'b', 'time' => time()], 60);

投递类

投递的类需要继承 HashedWheelTimerRunnable


All versions of hashed-wheel-timer-plugin with dependencies

PHP Build Version
Package Version
Requires esd/esd-coroutine Version ~0.8
esd/redis-plugin Version ~0.19
ext-bcmath 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 esd/hashed-wheel-timer-plugin contains the following files

Loading the files please wait ....