|
1 | 1 | [](https://github.com/hareland/multi-cache-remember/actions/workflows/pest.yml)
|
2 | 2 | ### What does this package solve?
|
3 | 3 |
|
4 |
| -This package offers the rememberMany macro for the Laravel Cache facade, providing efficient retrieval of multiple cache keys with customizable expiration and callbacks for missing keys. |
| 4 | +--- |
5 | 5 |
|
| 6 | +This package offers the rememberMany macro for the Laravel Cache facade, providing efficient retrieval of multiple cache keys with customizable expiration and callbacks for missing keys. |
6 | 7 |
|
| 8 | +--- |
7 | 9 | > The rememberMany macro for the Laravel Cache facade provides several advantages over the traditional method of
|
8 | 10 | > looking up multiple cache keys one by one.
|
9 | 11 |
|
10 |
| -### And...? |
11 |
| -1. Reduced number of cache lookups: With the traditional method, each cache key is looked up individually, even if some |
12 |
| - of them are being retrieved in quick succession. With the rememberMany macro, all the requested keys are retrieved |
13 |
| - in a single call to Cache::many(), which can significantly reduce the number of cache lookups and improve |
14 |
| - performance. |
15 | 12 |
|
16 |
| -2. Customizable cache expiration: The rememberMany macro allows you to specify an expiration time for all the cached |
17 |
| - values at once, which can simplify the cache management process and make it easier to ensure that your cached data is |
18 |
| - up-to-date. |
19 |
| - |
20 |
| -3. Callbacks for missing keys: The rememberMany macro allows you to specify a callback function for each cache key, |
21 |
| - which will be called only if the key is not found in the cache. This is similar to the `Cache::remember()` method. |
22 | 13 |
|
23 | 14 | ### Install
|
24 | 15 |
|
25 | 16 | ```bash
|
26 | 17 | composer require hareland/multi-cache-remember
|
27 | 18 | ```
|
28 | 19 |
|
29 |
| -### Register ServiceProvider (if you need to) |
| 20 | +### Register ServiceProvider (if you must) |
30 | 21 |
|
31 | 22 | ```php
|
32 | 23 | // in config/app.php
|
@@ -62,4 +53,22 @@ use Illuminate\Support\Facades\Cache;
|
62 | 53 | 'dashboard.stats.sales:org:3' => [fn() => \App\Models\StatsForOrf::findFor(request()->user()->currentOrg), 60 * 5],
|
63 | 54 | 'dashboard.stats.overview:org:3' => fn() => \App\Models\OverviewStats::findFor(request()->user()->currentOrg),
|
64 | 55 | ], 60); // 60 seconds is the default TTL for any keys that does not have a custom one.
|
65 |
| -``` |
| 56 | +``` |
| 57 | +--- |
| 58 | + |
| 59 | +[](https://www.buymeacoffee.com/hareland) |
| 60 | + |
| 61 | +--- |
| 62 | +### And...? |
| 63 | +1. Reduced number of cache lookups: With the traditional method, each cache key is looked up individually, even if some |
| 64 | + of them are being retrieved in quick succession. With the rememberMany macro, all the requested keys are retrieved |
| 65 | + in a single call to Cache::many(), which can significantly reduce the number of cache lookups and improve |
| 66 | + performance. |
| 67 | + |
| 68 | +2. Customizable cache expiration: The rememberMany macro allows you to specify an expiration time for all the cached |
| 69 | + values at once, which can simplify the cache management process and make it easier to ensure that your cached data is |
| 70 | + up-to-date. |
| 71 | + |
| 72 | +3. Callbacks for missing keys: The rememberMany macro allows you to specify a callback function for each cache key, |
| 73 | + which will be called only if the key is not found in the cache. This is similar to the `Cache::remember()` method. |
| 74 | + |
0 commit comments