Download the PHP package webfiori/cache without Composer

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

WebFiori Cache

A simple, secure, and highly customizable caching engine for PHP. This library provides time-based caching with built-in encryption support, making it suitable for application-level, server-level, and database-level caching scenarios.

Features

Table of Contents

Installation

Using Composer

Manual Installation

  1. Download the latest release from GitHub releases
  2. Extract the files to your project directory
  3. Include the library in your project:

Note: Manual installation is not recommended. Use Composer for automatic dependency management.

Supported PHP Versions

This library requires PHP 8.1 or higher.

Build Status

Quick Start

Usage

Basic Operations

Creating Cache Items

Retrieving Items

Retrieve Only:

Retrieve or Create:

Other Operations

Check Item Existence:

Remove Single Item:

Clear All Cache:

Update TTL:

Enable/Disable Caching:

Advanced Usage

Working with Cache Items

Key Prefixing

Dependency Injection

For modern applications, use dependency injection instead of static methods:

Security Configuration

Environment Variables

Set these environment variables for security configuration:

Programmatic Configuration

Custom Storage Drivers

Implement the Storage interface to create custom storage backends:

API Reference

Cache Class (Static Methods)

Method Description Parameters Returns
get($key, $generator, $ttl, $params) Retrieve or create cache item string $key, callable $generator, int $ttl = 60, array $params = [] mixed
set($key, $data, $ttl, $override) Store cache item string $key, mixed $data, int $ttl = 60, bool $override = false bool
has($key) Check if item exists string $key bool
delete($key) Remove cache item string $key void
flush() Clear all cache - void
getItem($key) Get detailed item info string $key Item\|null
setTTL($key, $ttl) Update item TTL string $key, int $ttl bool
isEnabled() Check if caching is enabled - bool
setEnabled($enable) Enable/disable caching bool $enable void
setDriver($driver) Set storage driver Storage $driver void
getDriver() Get current storage driver - Storage
withPrefix($prefix) Set key prefix string $prefix Cache

Item Class

Method Description Returns
getKey() Get item key string
getData() Get raw data mixed
getDataDecrypted() Get decrypted data mixed
getDataEncrypted() Get encrypted data string
getTTL() Get time-to-live int
getCreatedAt() Get creation timestamp int
getExpiryTime() Get expiry timestamp int
setTTL($ttl) Set time-to-live void
generateKey() Generate encryption key (static) string

Storage Interface

Method Description Parameters
store($item) Store cache item Item $item
read($key, $prefix) Read item data string $key, ?string $prefix
readItem($key, $prefix) Read item object string $key, ?string $prefix
has($key, $prefix) Check item existence string $key, ?string $prefix
delete($key) Delete item string $key
flush($prefix) Clear cache ?string $prefix

Configuration

Environment Variables

Variable Description Default Example
CACHE_ENCRYPTION_KEY 64-char hex encryption key Required a1b2c3d4e5f6...
CACHE_ENCRYPTION_ENABLED Enable/disable encryption true true\|false
CACHE_ENCRYPTION_ALGORITHM Encryption algorithm aes-256-cbc aes-256-gcm
CACHE_FILE_PERMISSIONS Cache file permissions 600 644
CACHE_DIR_PERMISSIONS Cache directory permissions 700 755

File Storage Configuration

The default FileStorage class stores cache files in the WebFiori/Cache/cache directory. You can customize this:

Security

Encryption

File Permissions

Best Practices

  1. Always set an encryption key in production environments
  2. Use environment variables for sensitive configuration
  3. Regularly rotate encryption keys for high-security applications
  4. Set appropriate file permissions for your environment
  5. Use prefixes to isolate different application components
  6. Implement proper error handling for cache operations

Key Generation

Error Handling

The library provides specific exceptions for different error conditions:

Performance Tips

  1. Use appropriate TTL values - longer for stable data, shorter for frequently changing data
  2. Implement cache warming for critical data
  3. Use key prefixes to organize and manage cache efficiently
  4. Monitor cache hit rates to optimize your caching strategy
  5. Consider cache size limits when using file storage
  6. Use dependency injection in modern applications for better testability

Examples

Web Application Session Caching

Database Query Caching

API Response Caching

License

This library is licensed under MIT License. See LICENSE file for more details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite: composer test
  6. Submit a pull request

Support


All versions of cache with dependencies

PHP Build Version
Package Version
No informations.
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 webfiori/cache contains the following files

Loading the files please wait ....