Download the PHP package phpixie/cache without Composer

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

Cache

PHPixie Cache library

Build Status Author Source Code Software License

The PHPixie Cache component supports both PSR-6 and PSR-16 standards and also adds a few useful features.

Initializing

If you are using the PHPixie framework the component is accessible via your builder and configured in /assets/config/cache.php.

Like all the other PHPixie components you can use it without the framework, in that case initialize it like so:

Configuration

Similarly to how you configure database connections, you can define multiple storage configurations using the available drivers: void, memory, phpfile, memcached and redis:

Usage

As mentioned PHPixie Cache supports both PSR-6 and the new simplified PSR-16. You will mostly use instances of the PHPixie\Cache\Pool interface:

Some examples:

There's no point to rewrite here all the usage examples for these PSRs which already have great documentation. The additional methods like delete, clear, etc. are very intuitive easy to find in PSR docs and by using IDE hints. Let's instead focus on some unique features.

Prefixed pools

When multiple parts of the application use the same cash storage a common practice is to prefix keys. How often have you seen code like this:

If these entities are cached in different parts of the application you have to make sure you are always using the same prefix or even abstract this logic into a separate service. PHPixie Cache solves this problem using a prefixed pools that proxy requests to the storage automatically prefixing the keys:

As you probably guessed such pools also implement the same PHPixie\Cache\Pool interface as the storages and can themselves be prefixed thus creating a hierarchy. They can be used to define different pools for different entities and also make it easy to later switch some of them to actual separate storages if needed. For example you can start out with one cache storage and multiple prefixed pools and expand easily when your application grows.

Simple usage without storages

The PHPixie\Cache class itself also implements the Pool interface and will proxy requests to the default cache storage. This makes the component easier to use in application with only one cache storage:

Not hashing the keys

Most filesystem caches hash the key to generate the appropriate file name, this is done to protect you from using keys that contain characters not supported by the filesystem. In reality most people use alphanumeric cache keys anyway and hashing these provides no real value but makes cache files harder to inspect and makes a slight impact on the application performance. PHPixie Cache uses raw keys for filenames, although hashing can easily be introduced if required.

Optimized file cache

Most cache libraries serialize the value together with the expiry timestamp to store it in a file cache. This approach has two drawbacks: everytime you read the value you have to deserialize it which impacts performance when used frequently, also to just check if the cache has not yet expired you have to deserialize the entire file, which is wasteful if the actual value is not used afterwards. So how does PHPixie Cache solve these? Let's look at an example of a cached file:

The first line contains a comment with the expiry timestamp, which can be checked simply by reading this one line ignoring the rest of the file. Also the cache is stored as PHP code which is retrieved using the include operator. This means that your opcache will cache it and not actually read the file from disk every time it is requested. This approach is especially great for usecases with singular writes and frequent reads like configuration cache etc. and can actually outperform other storages.

Contributing and adding drivers

Since PHPixie's social component got so much help from the community with adding new providers I decided to add a small guide on how to contribute and add your own storage driver to PHPixie Cache.

  1. Add a class PHPixie\Cache\Drivers\Type\YourDriver extending from PHPixie\Cache\Drivers\Driver.
  2. Register it in PHPixie\Cache\Builder::$driverMap.
  3. Create a test class PHPixie\Tests\Cache\Driver\YourDriverTest extending from PHPixie\Tests\Cache\DriverTest
  4. Edit .travis.yml and composer.json to add any necessary dependencies and packages so that your tests runs on Travis CI.
  5. Send in the Pull Request ;)

And of course our chatroom will be happy to help with any problems you encounter.


All versions of cache with dependencies

PHP Build Version
Package Version
Requires phpixie/slice Version ~3.0
psr/cache Version ^1.0
psr/simple-cache Version ^0.3.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 phpixie/cache contains the following files

Loading the files please wait ....