Created
July 21, 2020 10:14
-
-
Save dougblackjr/db60eb2f77973fc52ea1651c4b68ca18 to your computer and use it in GitHub Desktop.
Caching Inside a CraftCMS Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// To cache a variable | |
// function add($key, $value, $secondsToCache) | |
\Craft::$app->getCache()->add( | |
$nameOfCacheKey, | |
$valueToCache, | |
$numberOfSecondsToCache | |
); | |
// To retrieve the cache | |
// function get($key) | |
// Will return false if the cache is not available, or the cache has expired | |
$myCachedObject = \Craft::$app->getCache()->get($nameOfCacheKey); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment