Laravel Cache as an Alternative to WordPress Transients
Acorn provides Laravel integration with WordPress, which means that certain Laravel components are able to be used within your WordPress site.
Compared to WordPress transients API, Laravel Cache provides a more standardized and developer-friendly approach to caching data. It also has a wider range of cache storage options, compared to the WordPress Transients API, which only supports storing data in the WordPress database.
Review the Laravel Cache docs to get a more detailed understanding about how it works, along with the various ways that the cache can be configured
# Storing data in the cache
use Illuminate\Support\Facades\Cache;
Cache::put('key', 'value', $minutes);
# Retrieving data from the cache
use Illuminate\Support\Facades\Cache;
$value = Cache::get('key');
# Removing items from the cache
use Illuminate\Support\Facades\Cache;
Cache::forget('key');
You can also use Acorn's WP-CLI integration to interact with the cache:
$ wp acorn cache:clear
Contributors
Last updated
Support Roots
Help us continue to build and maintain our open source projects. We’re a small team of independent developers and every little bit helps.
Sponsor Roots on GitHub