PHPackages                             bigdevwhale/cachetastic - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. bigdevwhale/cachetastic

ActiveLibrary[Caching](/categories/caching)

bigdevwhale/cachetastic
=======================

A package for caching method results in Laravel

1.1.1(5mo ago)132.1k↓75.6%MITPHPPHP &gt;=7.2

Since Oct 27Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/bigdevwhale/cachetastic)[ Packagist](https://packagist.org/packages/bigdevwhale/cachetastic)[ RSS](/packages/bigdevwhale-cachetastic/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (7)Used By (0)

[![frankenstein](cachetastic.png)](cachetastic.png)

Cachetastic - Supercharge Your Laravel Caching!
===============================================

[](#cachetastic---supercharge-your-laravel-caching)

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Key Features](#key-features)
- [Use Cases](#use-cases)
- [Getting Started](#getting-started)
- [Examples](#examples)
- [Overwriting Cache Keys](#overwriting-cache-keys)
- [Contributing](#contributing)
- [License](#license)

Introduction
------------

[](#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
------------

[](#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 Read**y: Unit testing with PHPUnit and Mockery support included.

Use Cases
---------

[](#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)

Getting started with Cachetastic is a piece of cake. Follow these simple steps to integrate it into your Laravel project:

1. Install Cachetastic using Composer:

    ```
    composer require bigdevwhale/cachetastic
    ```
2. Configure the default [cache driver](https://laravel.com/docs/10.x/cache) in your Laravel application
3. Start caching method results with the Cachetastic class.

    ```
     // Import the Cachetastic class
     use Cachetastic\Cachetastic;

     // Create an instance of Cachetastic
     $cacheService = new Cachetastic(
         new YourApiService(), // The service or object to call the method on.
         'fetchData',          // The name of the method to call on the service.
         [1, 2]               // An array of parameters to pass to the method.
     );

     // Customize the cache duration (optional)
     $cacheService->setCacheDuration(60);

     // Cache the result of your API call
     $result = $cacheService->retrieveOrCache();

      // Force a clear of the cached data if needed
     $cacheService->forceClear();

     // Force refresh the cached data with new result
     $result = $cacheService->forceRefresh();
    ```
4. 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
----------------------

[](#constructor-parameters)

The Cachetastic 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
---------------------------

[](#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
-------

[](#example)

Here's an example of caching the result of a method in a Laravel application, whether it's a regular or static method:

```
use Cachetastic\Cachetastic;
use YourApiService;

// Create an instance of Cachetastic to cache the result of a regular method
$cacheService = new Cachetastic(
    new YourApiService(), // The service or object to call the method on.
    'fetchData',          // The name of the method to call on the service.
    [1, 2]               // An array of parameters to pass to the method.
);

// Customize the cache duration (optional)
$cacheService->setCacheDuration(60);

// Cache the result of your API call, whether it's a regular method
$result = $cacheService->retrieveOrCache();

// Create an instance of Cachetastic to cache the result of a static method
$cacheServiceStatic = new Cachetastic(
    YourApiService::class, // The class with the static method.
    'fetchDataStatic',    // The name of the static method to call.
    [1, 2]                // An array of parameters to pass to the static method.
);

// Cache the result of your API call, whether it's a static method
$resultStatic = $cacheServiceStatic->retrieveOrCache();
```

Overwriting Cache Keys
----------------------

[](#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
------------

[](#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
-------

[](#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!

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance72

Regular maintenance activity

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~164 days

Recently: every ~205 days

Total

6

Last Release

158d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a881cea8e4820ae067cd4d454854b04ab111c9f56f5bf05adb0cd03713591a4c?d=identicon)[Marat555](/maintainers/Marat555)

---

Top Contributors

[![bigdevwhale](https://avatars.githubusercontent.com/u/14868809?v=4)](https://github.com/bigdevwhale "bigdevwhale (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bigdevwhale-cachetastic/health.svg)

```
[![Health](https://phpackages.com/badges/bigdevwhale-cachetastic/health.svg)](https://phpackages.com/packages/bigdevwhale-cachetastic)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k90.5k1](/packages/mike-bronner-laravel-model-caching)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M131](/packages/laravel-pulse)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21111.6k](/packages/iazaran-smart-cache)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
