Download the PHP package bigdevwhale/cachetastic without Composer
On this page you can find all versions of the php package bigdevwhale/cachetastic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bigdevwhale/cachetastic
More information about bigdevwhale/cachetastic
Files in bigdevwhale/cachetastic
Package cachetastic
Short Description A package for caching method results in Laravel
License MIT
Informations about the package cachetastic
Cachetastic - Supercharge Your Laravel Caching!
Table of Contents
- Introduction
- Key Features
- Use Cases
- Getting Started
- Examples
- Overwriting Cache Keys
- Contributing
- License
Introduction
Welcome to Cachetastic, your secret weapon for optimizing caching in Laravel applications. This package supercharges your Laravel caching capabilities, making it a breeze to cache method results and improve your application's performance. Say goodbye to redundant API calls and database queries, and hello to lightning-fast responses!
Key Features
- Method-Level Caching: Cache the results of any method, whether regular or static, with ease.
- Flexible Cache Management: Force-refresh and update cache with new values on-demand.
- Automatic Cache Key Generation: Cache keys are generated based on method name and parameters.
- Custom Parameter Keys: Users can specify parameter keys for cache key generation.
- Laravel Integration: Seamlessly integrates with Laravel's caching system.
- Clean and Elegant Code: Well-structured and efficient codebase for easy use and contribution.
- PHPUnit and Mockery Ready: Unit testing with PHPUnit and Mockery support included.
Use Cases
Cachetastic is the perfect addition to your Laravel project for various use cases:
- API Responses: Cache responses from external APIs to reduce latency and minimize rate limits.
- Database Queries: Cache complex database queries and boost query performance.
- Expensive Computation: Cache the results of computationally intensive methods for faster execution.
- Dynamic Content: Cache dynamic content to reduce server load and improve user experience.
- Rate-Limited APIs: Avoid exceeding rate limits by caching API responses and serving cached data.
Cachetastic is your go-to tool for optimizing your Laravel application's performance in a snap!
Getting Started
Getting started with Cachetastic is a piece of cake. Follow these simple steps to integrate it into your Laravel project:
-
Install Cachetastic using Composer:
- Configure the default cache driver in your Laravel application
-
Start caching method results with the CacheService class.
- Customize caching, force refresh, and error handling according to your needs.
That's it! Cachetastic seamlessly enhances your caching capabilities with minimal effort.
Constructor Parameters
The CacheService constructor requires the following parameters:
- service: The service or object to call the method on.
- method: The name of the method to call on the service.
- params: An array of parameters to pass to the method.
Cache Customization Methods
Cachetastic provides the following methods for customizing caching:
- setCacheDuration(int $cacheDuration): Set the cache duration in minutes.
- setCacheKeyParams(array $cacheKeyParams): Set parameter keys to use for cache key generation.
- setCustomCacheKey(string $customCacheKey): Set a custom cache key to be used instead of generating one.
By default, the cache duration is set to 60 minutes.
You can use these methods to further customize your caching experience.
Example
Here's an example of caching the result of a method in a Laravel application, whether it's a regular or static method:
Overwriting Cache Keys
Please note that if two methods are executed in the same class with only array parameters, they will overwrite each other's cache value since only scalar parameters are used for cache key generation. In this case, consider using the setCustomCacheKey method described above.
Contributing
We welcome contributions from the open-source community. Feel free to submit bug reports, feature requests, or pull requests on our GitHub repository.
License
Cachetastic is open-source software licensed under the MIT License.
Supercharge your Laravel application with Cachetastic and turbocharge your caching game! Give it a try and experience the benefits for yourself. Happy caching!