cache_set('cache_key_goes_here', 'cache_data_goes_here', 'cache', time() + 60);
$cache = cache_get('cache_key_goes_here');
if (!empty($cache->data) && time() < $cache->expire) {
// Do something with $cache->data here.
}
\Drupal::cache()->set('cache_key_goes_here', 'cache_data_goes_here', time() + 60);
$cache = \Drupal::cache()->get('cache_key_goes_here');
if (!empty($cache->data) {
// Do something with $cache->data here.
}
Note that in Drupal 8 you don't have to manually check to make sure the cache isn't expired, thanks to this issue.