Download the PHP package nickjbedford/block-cache without Composer

On this page you can find all versions of the php package nickjbedford/block-cache. 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 block-cache

BlockCacher

BlockCacher provides an efficient file-based caching mechanism that can store serialised data, text and HTML content using simple store and get methods. HTML and data generation times can be reduced to fractions of a millisecond after caching, and this cacher is designed to be used wherever it can.

It provides straight-forward key-based storage and retrieval as well as start/end output buffer caching as well as lazy data generation.

Keys are directly used as filenames on disk, allowing key-based cache clearing using wildcards. The file system is now abstracted through the BlockCacher\IFileSystem interface so it can be replaced with other file-systems.

Usage

You must first instantiate an instance of BlockCacher with a cache storage directory. Only single-level cache directories are supported. Cache keys must not include sub-directories.

The first instance of BlockCacher will become the default and can then be retrieved through the global blockCacher() function, or BlockCacher::getDetault().

The cache directory specified will be created by default if it does not exist, although this can be prevented in the constructor parameters.

BlockCacher is not a singleton but it does provide a default instance capability. This allows other cache directories to be used in parallel for more specific use cases.

Storing & Retrieving Values

BlockCacher doesn't store expiry times and instead asks for the maximum age of the cache whenever cached data is to be retrieved. This removes the need to "package" values with expiry times when they are being stored on the disk.

Storing Text & Data

To store data in the cache, use the store() and storeText() methods.

Retrieve Text & Data

To retrieve data from the cache, use the get() and getText() methods. Pass in the maximum age of the cache in seconds to ensure that existing cache files that over the desired age are ignored. The default expiry lifetime is set to 86,400 seconds, or one day.

NOTE: Cache files are ignored but not deleted if they have expired.

Generating Blocks of HTML, Text & Data

BlockCacher includes helper methods for generating blocks of HTML content and serialisable data. These are start() + end() as well as generate() + html().

Generating HTML Blocks

The start() method determines if a block should be regenerated based on the cache status then starts a buffer if there is a cache miss. The end() method then closes the buffer, stores the contents and echoes it.

The end() method must be called outside the if() statement. This will echo the content and clean up the buffer stack regardless of the status of the cache.

Lazily Generating Data

To generate cacheable data only if necessary, use the generate() method, which takes a closure that will generate the data to be cached if it does not already exist.

Lazily Generating Text (or HTML)

To generate cacheable text only if necessary, use the generateText() method, which takes a closure that will generate the text to be cached if it does not already exist.

An Alternative For HTML

You can now use the new html() function and pass an output buffer generator function. This functions similarly to generate() except that the generator function should echo its content directly to the output buffer, not return it to the cacher method.

The HTML content can then be echoed to the higher level output buffer.

Clearing Caches

Since cached data and text is stored in files under the cache directory, clearing caches uses glob file patterns. Use the clear() method and specify a filename or file pattern.

NOTE: Regular Cache Pruning

It can be prudent to prune old files regularly in large systems to ensure the clear() is fast when matching file patterns. With hundreds of thousands of cache files, glob() can take a long time to build its list of matching files.

clear() takes an optional $minimumAge parameter to specify the minimum age of files that can be cleared.

File System Interface

Version 0.4 introduces the new BlockCacher\IFileSystem interface. By default, the BlockCacher\NativeFileSystem implementation is used, which wraps the existing native IO functions that were used by BlockCacher.

To use a different file system, implement the IFileSystem interface then pass in an instance of your class to the BlockCacher constructor.


All versions of block-cache with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
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 nickjbedford/block-cache contains the following files

Loading the files please wait ....