PHPackages                             deathkel/easy-cache - 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. deathkel/easy-cache

ActiveLibrary[Caching](/categories/caching)

deathkel/easy-cache
===================

A Trait to use cache easily for Laravel

0.0.1(9y ago)1134MITPHPPHP &gt;=7.0

Since Apr 13Pushed 7y ago2 watchersCompare

[ Source](https://github.com/deathkel/easy-cache)[ Packagist](https://packagist.org/packages/deathkel/easy-cache)[ Docs](https://github.com/deatkel/EasyCache)[ RSS](/packages/deathkel-easy-cache/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

A Trait to use cache easily for Laravel
=======================================

[](#a-trait-to-use-cache-easily-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/26fb3a167621d8a7323362a3a439e60d8c6ddd3d729c09211d580cce0b4b771f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64656174686b656c2f656173792d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/deathkel/easy-cache)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/3ca96ff5aab2df95c51129e9161c76545ea7a1e1a0cf5faa17b74950223a9887/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f64656174686b656c2f656173792d63616368652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/deathkel/easy-cache)[![Quality Score](https://camo.githubusercontent.com/58e81e01e18a4bb1252e27d7c9516ee21aa954337c379c1f639d0748f15655b2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f64656174686b656c2f656173792d63616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/deathkel/easy-cache)[![Total Downloads](https://camo.githubusercontent.com/579d05adcf030b345a986e63f909651eba9fe0bc31dae26539f01950e49a10d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64656174686b656c2f656173792d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/deathkel/easy-cache)

INSTALL
-------

[](#install)

`composer require deathkel/easy-cache`

USAGE
-----

[](#usage)

- this trait will auto cache protect function
- default cache time is 60 minutes. you can define a `static` variable `$expire` for each function

```
public class test(){

    use EasyCacheTrait;

    public function __construct(){
        $this->default_expire = 1; //change default expire time (min)
    }

    public function DontWantToBeCache(){ // public function will not be cached
        //.....
    }

    protected function WantToBeCache(){ // protected function will be cached automatically
        static $expire = 60; //minute that this function want to be cached
    }

    private static function _getCacheKeyPrefixLevel1(){
        return "test:"; //overwrite cache prefix level 1, default is class name
    }

    private static function _getCacheKeyPrefixLevel2($method){
        return self::_getCacheKeyPrefixLevel1() . $method . ":"; //overwrite cache prefix level 2
    }

    private static function _getCacheKey($method, $params){
        return self::_getCacheKeyPrefixLevel2($method) . md5(json_encode($params)); //overwrite cache key
    }
}
```

### delete cache

[](#delete-cache)

- call method `forgetCache` to delete all cache in class
- call method `forgetMethodCache` to delete all cache in the method

### when in debug pattern

[](#when-in-debug-pattern)

- add 'skipCache=1' to http query param will skip cache and exec function
- add 'forgetCache=1' to http query param will forget cache and restore cache

TODO
----

[](#todo)

- add test example

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

3367d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/14328715?v=4)[KEL](/maintainers/deathkel)[@deathkel](https://github.com/deathkel)

---

Top Contributors

[![deathkel](https://avatars.githubusercontent.com/u/14328715?v=4)](https://github.com/deathkel "deathkel (14 commits)")

---

Tags

cachelaravel

### Embed Badge

![Health badge](/badges/deathkel-easy-cache/health.svg)

```
[![Health](https://phpackages.com/badges/deathkel-easy-cache/health.svg)](https://phpackages.com/packages/deathkel-easy-cache)
```

###  Alternatives

[beryllium/cachebundle

Provides an interface to Memcache for Symfony2 applications

32136.0k](/packages/beryllium-cachebundle)

PHPackages © 2026

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