PHPackages                             railken/cacheable - 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. railken/cacheable

ActiveLibrary[Caching](/categories/caching)

railken/cacheable
=================

v0.2.0(2y ago)024.8k4MITPHPPHP &gt;=8.1

Since May 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/railken/cacheable)[ Packagist](https://packagist.org/packages/railken/cacheable)[ RSS](/packages/railken-cacheable/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (8)Used By (4)

Cacheable
=========

[](#cacheable)

[![Actions Status](https://github.com/railken/cacheable/workflows/Test/badge.svg)](https://github.com/railken/cacheable/actions)

This library give you the ability to call any method with a suffix `Cached` to retrieve a Cached result of the methods. This comes in handy when you have a really time consuming method and the result is always be the same given the same parameters

Requirements
============

[](#requirements)

- PHP 8.1 and later
- Laravel

Installation
------------

[](#installation)

You can install it via [Composer](https://getcomposer.org/) by typing the following command:

```
composer require railken/cacheable
```

Usage
-----

[](#usage)

Add the `CacheableTrait` and `CacheableContract` in the class you wish to cache

```
use Railken\Cacheable\CacheableTrait;
use Railken\Cacheable\CacheableContract;

class Foo implements CacheableContract
{
  use CacheableTrait;

  public function sum(int $x, int $y): int
  {
      return $x + $y;
  }

  public function random(): string
  {
      return str_random(10);
  }
}
```

Now you can play with the method

```
$foo = new Foo();
$foo->sumCached(2, 8); // 10

$foo->randomCached(); // Return always the same string
```

In order to cleanup the cache simply run `php artisan cache:clean`

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~298 days

Recently: every ~446 days

Total

7

Last Release

817d ago

PHP version history (2 changes)v0.1.0PHP &gt;=7.1

v0.2.0PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![railken](https://avatars.githubusercontent.com/u/26530231?v=4)](https://github.com/railken "railken (22 commits)")

---

Tags

cachecacheablelaravelmethodstraitlaravelcacheable

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/railken-cacheable/health.svg)

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

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

974169.8k2](/packages/awssat-laravel-visits)[yangusik/laravel-balanced-queue

Laravel queue management with load balancing between partitions (user groups)

8512.6k](/packages/yangusik-laravel-balanced-queue)[karriere/state

Laravel package for storing current application state in cache/session

1719.0k](/packages/karriere-state)

PHPackages © 2026

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