Download the PHP package ngmy/cached-object without Composer
On this page you can find all versions of the php package ngmy/cached-object. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ngmy/cached-object
More information about ngmy/cached-object
Files in ngmy/cached-object
Package cached-object
Short Description A caching scheme for an object for Laravel 4, inspired by Enterprise Rails
License MIT
Homepage https://github.com/ngmy/cached-object
Informations about the package cached-object
Cached Object
A caching scheme for an object for Laravel 4, inspired by Enterprise Rails.
Requirements
The Cached Object has the following requirements:
-
PHP 5.3+
- Laravel 4.0+
Installation
Add the package to your composer.json
and run composer update
:
Add the following to the list of service providers in app/config/app.php
:
Add the following to the list of class aliases in app/config/app.php
:
Examples
Basic Usage
-
Create a physical model, which inherits from Eloquent:
-
Create a logical model, which inherits from CachedObject:
You need to define
$VERSION
. This property is used to create a unique cache key for a requested object. Please increments this number when you change a structure of a class. -
Create a logical model of an uncached version, which a class name starts with Uncached:
In order to get an object of a logical model, you need to define a method whose name starts with get. This method is called only if an object does not exist in a cache.
- Now, you can get an object from a cache by calling
Movie::get()
.
Physical Model Observers
-
Create a observer.
For example, to rebuild a cache when you updated a physical model, and also to delete a cache when you deleted a physical model, define a observer as follows:
- Register a observer to a physical model:
More Usage
Please see my unit tests.