You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 6, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,4 +49,28 @@ class Model extends \Eloquent
49
49
50
50
Caching the model only works with using the `find`, `findMany` or `findOrFail` methods.
51
51
52
-
If you would like caching behavior like in Laravel 4 then consider using [dwightwatson/rememberable](https://github.com/dwightwatson/rememberable) which adds the `remember` function back into eloquent.
52
+
If you would like caching behavior like in Laravel 4 then consider using [dwightwatson/rememberable](https://github.com/dwightwatson/rememberable) which adds the `remember` function back into eloquent.
53
+
54
+
You can optinally set the expiry time in minutes for the model, by default it is set to `1440` minutes (24 hours).
55
+
56
+
```php
57
+
<?php
58
+
59
+
namespace App;
60
+
61
+
use PulkitJalan\Cacheable\Cacheable;
62
+
63
+
class Model extends \Eloquent
64
+
{
65
+
use Cacheable;
66
+
67
+
/**
68
+
* Set the cache expiry time.
69
+
*
70
+
* @var int
71
+
*/
72
+
public $cacheExpiry = 60;
73
+
}
74
+
```
75
+
76
+
Models are cached using the models `table name` as the cache tag and the `id` as the key. There are observers which get registered in the trait to also remove from cache when the `updated`, `saved` or `deleted`.
0 commit comments