Skip to content

Instantly share code, notes, and snippets.

@putzflorian
Created January 29, 2019 13:50
Show Gist options
  • Save putzflorian/8ffee1c1f4bc736c7650e205bf1dfa05 to your computer and use it in GitHub Desktop.
Save putzflorian/8ffee1c1f4bc736c7650e205bf1dfa05 to your computer and use it in GitHub Desktop.
<?php
$actual_hour = date('H');
$condition[] = 'hour_' . $actual_hour;
$lifetime = 3600; // 1h
$mdCondition = md5($condition);
if (!Cache::load($mdCondition)) {
$objects->setOrderKey("RAND($actual_hour)", false);
Cache::save(
$objects,
$mdCondition,
[],
$lifetime);
} else {
p_r("im cache");
$cachedObjects = Cache::load($mdCondition);
p_r($cachedObjects);
$objects = $cachedObjects;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment