Download the PHP package emileperron/magic-cache without Composer
On this page you can find all versions of the php package emileperron/magic-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download emileperron/magic-cache
More information about emileperron/magic-cache
Files in emileperron/magic-cache
Package magic-cache
Short Description An easy to use caching library that uses Symfony's FilesystemAdapter under the hood.
License MIT
Informations about the package magic-cache
MagicCache: a simple PHP caching library
MagicCache is a simple caching library that wraps Symfony's FilesystemAdapter in order to give you the simplest caching experience possible.
If you have a small project that requires caching, or have a large project with very simple caching needs, this library is for you.
The highlight of this library are the Cache::magicGet()
and Cache::magicSet()
method, which allow you to save or retrieve data from the cache without having to define unique cache keys yourself. More details on that below.
Getting started
To get started, simply require the package via Composer:
Once that's done, you can start using the library in your project. Here's a very brief overview of the library's usage and functionalities:
Magic get()
and set()
methods
This library defines two magic methods: magicGet()
and magicSet()
. These methods automatically generate a cache key based on the calling function's class, name and parameters.
This won't always be usable (ex.: if you are passing entire files or data stream in your function's parameters), but it works for a lot of simple use cases, which are much more common anyway.
Both methods accept a $suffixes
parameter, which allow you to pass your own unique identifier(s) in the form of an array. Those suffixes will then be used instead of the calling function's parameters. The calling function's class and name will still be used in order to generate a unique cache key for that specific method.
Contributing
Feel free to submit pull requests on the GitHub repository if you want to add functionalities or suggest improvements to this library. I will look them over and merge them as soon as possible.
You can also submit issues if you run into problems but don't have time to implement a fix.
Supporting
Finally, if you use the library and would like to support me, here are the ways you can do that:
- Saying thanks directly on Twitter: @cunrakes
- Giving this repository a star on GitHub
- Taking a look at my other projects on my website
- Buying me a cup of tea ☕️