Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

H33Tx/Cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

8 Commits

Repository files navigation

Cache - PHP File-Based Cache

This is a simple PHP file-based caching system with support for cache monitoring and encryption. It allows you to securely cache data and monitor cache usage in your PHP applications.

Features

  • File-based caching: Data is stored in files on the filesystem.
  • Cache monitoring: Track cache hits, misses, and cache size.
  • Encryption support: Encrypt cached data for security.
  • Customizable expiry: Set expiry time for cached data.

Installation

  1. Clone the repository or download the Cache.php file.
  2. Include the Cache.php file in your PHP project.

Usage

1. Initialization

// Include the Cache class
require_once "Cache.php";
// Create a new Cache instance with cache directory and encryption key
$cache = new Cache("./cache", "my_secret_key");

2. Caching Data

// Cache data with optional expiry time (default: no expiry)
$cache->set("key", "value", 3600); // Cache "value" with key "key" for 1 hour

3. Retrieving Data

// Retrieve cached data
if ($cachedData = $cache->get("key");) {
 echo "Cached data: " . $cachedData; // return "value" - if set
} else {
 echo "Data not found in cache.";
 // You now may execute a call to the Database and then set the cache
}

4. Clearing Cache

// Clear cache for a specific key
$cache->clearCache("key");
// Clear entire cache
$cache->clearCache();

5. Retrieving Cache Hits and Misses

// Get cache hits and misses
echo "Cache Hits: " . $cache->getCacheHits() . PHP_EOL;
echo "Cache Misses: " . $cache->getCacheMisses() . PHP_EOL;

6. Retrieving Cache Size

// Get cache size
echo "Cache Size: " . $cache->getCacheSize() . " bytes" . PHP_EOL;

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

This project is licensed under the GPL-3.0 license - see the LICENSE file for details.

About

Powerful PHP-Caching-Class with encryption and (somewhat) monitoring.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /