Download the PHP package purpleharmonie/cache without Composer

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

Purple Cache Library

Overview

The Purple Cache Library provides a flexible caching mechanism for your application with support for various cache types including Redis, file-based, and in-memory caching. This library adheres to the PSR-16 caching interface for standardization and ease of use.

Installation

To install the Purple Cache Library, use Composer:

Cache Types

Redis Cache

A cache implementation using Redis for storage.

File Cache

A cache implementation using the file system for storage.

In-Memory Cache

A cache implementation using the application memory for storage.

Factory Class: PurpleCacheFactory

The PurpleCacheFactory class is responsible for creating instances of different cache types. It provides a single method, createCache, which takes a cache type and an optional configuration array.

Usage

Create a Redis Cache

Create a File Cache

Create an In-Memory Cache

Cache Interface

PSR-16 Methods

All cache implementations (RedisCache, FileCache, InMemoryCache) adhere to the Psr\SimpleCache\CacheInterface. Here are the available methods:

Example: FileCache

The FileCache class provides a file-based caching mechanism.

Constructor

Methods

get($key, $default = null)

Retrieves the value of a cache item.

set($key, $value, $ttl = null): bool

Stores a value in the cache.

delete($key): bool

Deletes a cache item.

clear(): bool

Clears the entire cache.

getMultiple($keys, $default = null): iterable

Retrieves multiple cache items.

setMultiple($values, $ttl = null): bool

Stores multiple values in the cache.

deleteMultiple($keys): bool

Deletes multiple cache items.

has($key): bool

Checks if a cache item exists.

getMetrics(): array

Returns cache metrics such as hit count, miss count, hit ratio, and item count.

Configuration

Redis Cache Configuration

File Cache Configuration

In-Memory Cache Configuration

Eviction Policies

LRU (Least Recently Used)

Evicts the least recently accessed items first.

LFU (Least Frequently Used)

Evicts the least frequently accessed items first.

Metadata Management

The FileCache class manages metadata to track cache item access and frequency. Metadata is stored in a file (metadata.php) within the cache directory.

Methods

Metrics

The getMetrics() method in each cache implementation returns an array of cache metrics:

Example

Error Handling

The library throws InvalidArgumentException for invalid cache keys and configurations. Ensure to handle these exceptions in your application code.

Conclusion

The Purple Cache Library provides a robust caching solution with support for Redis, file-based, and in-memory caching. By adhering to PSR-16 standards, it ensures interoperability and ease of integration with other libraries and frameworks. Configure and use the cache that best suits your application's needs and manage cache efficiently with eviction policies and metrics tracking.


All versions of cache with dependencies

PHP Build Version
Package Version
Requires psr/simple-cache Version ^3.0
predis/predis Version ^2.2
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 purpleharmonie/cache contains the following files

Loading the files please wait ....