Download the PHP package bayfrontmedia/leaky-bucket without Composer

On this page you can find all versions of the php package bayfrontmedia/leaky-bucket. 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 leaky-bucket

Leaky Bucket

Framework-agnostic throttling using the leaky bucket algorithm.

A bucket has a defined capacity and leak rate per minute. Buckets can also store additional arbitrary data.

License

This project is open source and available under the MIT License.

Author

Bayfront Media

Requirements

Installation

Usage

Storage adapter

A Bayfront\LeakyBucket\ApadpterInterface must be passed to the Bayfront\LeakyBucket\Bucket constructor. There are a variety of storage adapters available, each with their own required configuration.

Flysystem

The Flysystem adapter allows you to use a Flysystem League\Flysystem\Filesystem v3 instance for bucket storage.

Local

The Local adapter allows you to store buckets locally using native PHP.

PDO

The PDO adapter allows you to use a \PDO instance for bucket storage into a database.

The PDO adapter will create/use a table named "buckets" unless otherwise specified in the constructor.

Use the up method to create the necessary database table to be used by this adapter. Use the down method to remove the database table.

These methods throw a Bayfront\LeakyBucket\AdapterException exception.

Start using Leaky Bucket

Once your adapter has been created, it can be used with Leaky Bucket. In addition, an optional settings array can be passed to the constructor. The default settings are shown below.

NOTE: Be sure to leak() the bucket before attempting to do any calculations regarding its capacity. Also, the save() method must be used to store the current bucket settings for future use.

Public methods


exists

Description:

Checks if this bucket ID already exists in storage.

Parameters:

Returns:

Example:


save

Description:

Saves the bucket.

Parameters:

Returns:

Throws:

Bayfront\LeakyBucket\AdapterException

Example:


get

Description:

Returns entire bucket contents.

Parameters:

Returns:

Example:


reset

Description:

Reset all bucket information and data.

Parameters:

Returns:

Example:


delete

Description:

Resets bucket and deletes the file in storage.

Parameters:

Returns:

Throws:

Bayfront\LeakyBucket\AdapterException

Example:


isFull

Description:

Checks if bucket is full.

Parameters:

Returns:

Example:


getCapacity

Description:

Returns the total bucket capacity.

Parameters:

Returns:

Example:


getCapacityUsed

Description:

Returns the number of drops in the bucket.

Parameters:

Returns:

Example:


getCapacityRemaining

Description:

Returns the remaining bucket capacity.

Parameters:

Returns:

Example:


hasCapacity

Description:

Checks if bucket has the capacity fo fill by a given number of drops.

Parameters:

Returns:

Example:


getLeakPerSecond

Description:

Returns the number of drops per second the bucket will leak.

Parameters:

Returns:

Example:


getSecondsPerDrop

Description:

Returns the number of seconds required to leak one drop.

Parameters:

Returns:

Example:


getSecondsUntilCapacity

Description:

Returns the number of seconds until bucket has capacity for number of drops. Returns 0 if bucket has capacity.

Parameters:

Returns:

Example:


getSecondsUntilEmpty

Description:

Returns the number of seconds until bucket would be empty.

Parameters:

Returns:

Example:


touch

Description:

Manually update the bucket's timestamp.

The bucket's timestamp is automatically updated when any of the following methods are called:

Parameters:

Returns:

Example:


getLastTime

Description:

Returns the bucket's last timestamp.

Parameters:

Returns:

Example:


fill

Description:

Fills the bucket with a given number of drops.

If not allowed to overflow, and the bucket does not have the required capacity, a Bayfront\LeakyBucket\BucketException will be thrown. Otherwise, the bucket will be allowed to overflow.

Parameters:

Returns:

Throws:

Example:


leak

Description:

Updates the bucket by calculating how many drops to leak since it's last timestamp.

Parameters:

Returns:

Example:


spill

Description:

Spills a given number of drops from the bucket.

Parameters:

Returns:

Example:


overflow

Description:

Dumps (empties) all drops from the bucket in excess of its capacity.

Parameters:

Returns:

Example:


dump

Description:

Dumps (empties) all drops from the bucket.

Parameters:

Returns:

Example:


hasData

Description:

Checks if this bucket contains any additional data, or a specific key in dot notation.

Parameters:

Returns:

Example:


setData

Description:

Sets additional data for this bucket in dot notation.

Parameters:

Returns:

Example:


getData

Description:

Returns this bucket's additional data key in dot notation, or an optional default value if not found.

Parameters:

Returns:

Example:


forgetData

Description:

Removes additional data key in dot notation for this bucket.

Parameters:

Returns:

Example:


All versions of leaky-bucket with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-pdo Version *
ext-json Version *
bayfrontmedia/php-array-helpers Version ^2.0
league/flysystem Version ^3.14
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 bayfrontmedia/leaky-bucket contains the following files

Loading the files please wait ....