Download the PHP package beryllium/cache without Composer

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

Beryllium\Cache 2.0

This library provides an implementation of PSR-16 "Simple Cache", with some added functionality.

Several cache clients are included:

As well as some wrappers that can provide additional functionality:

Documentation for the PSR-16 "Common Interface for Caching Libraries" can be found here: https://www.php-fig.org/psr/psr-16/

Basic Usage

  1. Instantiate a cache client
  2. Instantiate Beryllium\Cache with the cache client in the constructor
  3. If desired, set a custom TTL or custom prefix

Now you can get/set items in the cache:

Extra Functionality

Default TTL:

Beryllium\Cache allows you to set a default TTL that gets passed into the caching client, as well as a key prefix that gets attached to each key. This prefix can be helpful for namespacing, for example.

In the above example, the file created on-disk for the cache would be named %current_dir%/cache/www-latest-news-items_file.cache.

Prefix:

Beryllium\Cache supports 'prefixing' keys with a specific string, which may be useful in some caching systems. For example, it could be useful in the FilecacheClient to ensure that you can always identify cached files.

Cache Client Classes

ApcuClient

APCu (Alternate PHP Cache - user) is a way of using the shared PHP memory stack as a cross-process caching system. Items added to the stack can be accessed by other processes that are using the same stack.

I'm not sure if that entirely made sense, but regardless, it can be a very powerful and fast caching system.

Requires the APCu extension to be installed and enabled. Note that the extension is disabled by default in CLI mode.

Configuration:

Because this extension is disabled on the CLI, to run the unit tests for this client you have to set an INI value on the command line:

php -d apc.enable_cli=1 vendor/bin/phpunit

If you attempt to load this extension on a system where APCu is not installed, the class will generate fatal errors due to methods not being found. If you need it to fail silently, e.g., if you're using a Cascade wrapper, you can wrap it in the IgnoreThrowablesWrapper to silence the fatals. Or install APCu. Whichever works for you.

FilecacheClient

Filesystems are a great way to cache certain types of data. I don't know what those types are, but I'm quite sure the statement is true.

Configuration:

Most of the reason for the existence of a "prefix" feature in this lib is wrapped up in the original conception of the FilecacheClient. :)

If the path doesn't exist, that might result in an error state - but the lib will make an attempt to create it & ensure that it's writeable.

Because this client uses PHP's serialize/unserialize functionality, it should be considered quite a bit unsafe. Any process that has access to modify the cache files could potentially hijack the PHP process when unserialize is called. At least, several documented vulnerabilities in other projects seem to be traceable back to unsafe unserialization.

Help would be appreciated in making things a bit safer in that regard.

I've broken out the serialize/unserialize functionality into methods, so if you want, you could extend the FilecacheClient and override the serialization mechanism.

MemcachedClient

Memcache is a powerful library for caching. Some of that power has been "hidden" in this client implementation, but thanks to PSR-16 you can expect the cache to behave in a predictable way.

Quick Configuration:

The quick approach instantiates the Memcached class directly inside the constructor.

Injecting the Dependency:

If you would prefer, you can also inject the Memcached class directly:

If you have multiple servers, injecting the object would likely be the better way to go.

Server Verifier:

MemcachedClient also comes with a "server verifier" that attempts to ensure that the server is online before it tries to interact with it.

The "verifier" is completely optional, and can be a bottleneck. This behaviour is a holdover from the previous implementation. Perhaps it can be eliminated?

MemoryClient

This client stores cached items in an array inside itself. Mostly useful for tests, but could have some use as a way of accelerating processing within individual requests.

Configuration:

Cache Wrapper Classes

IgnoreThrowablesWrapper

This wrapper encapsulates a noisy Client class and ensures that no exceptions or errors escape it. Generally this causes the client to fail silently, which can be useful when you want your cache configuration to not blow up on a function-not-found error.

Or a path-not-found/path-not-writable error.

Configuration:

CascadeWrapper

The Cascade wrapper lets you stack cache clients together so that one call to ->get() will first check the closest/fastest cache (MemoryClient or ApcuClient), then start looking farther afield to find the requested data (Memcache, Filecache).

Calling ->set() will relay the ->set() to each client in sequence.

If ->enableBackfill() is called, a successful call to ->get() will also set all the cache targets, ensuring the full cache is populated.

Configuration:


All versions of cache with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.0
psr/simple-cache Version ^1.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 beryllium/cache contains the following files

Loading the files please wait ....