Skip to content

Instantly share code, notes, and snippets.

@dave1010
Created March 23, 2016 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dave1010/d4bba9cc98eded14c8e0 to your computer and use it in GitHub Desktop.
Save dave1010/d4bba9cc98eded14c8e0 to your computer and use it in GitHub Desktop.
Cache buster
interface CacheBuster
{
/**
* @return string version
* @throws \NoVersionException
*/
public function getVersion();
}
class MultipleCacheBuster
{
public function __construct($cacheBusers)
{
$this->cacheBusers = $cacheBusers;
}
public function getVersion()
{
// loop, with a catch
}
}
class WordPressCacheBusterBuilder
{
public function __consruct($someEnvStuff)
{
}
public function build()
{
$busters = [];
if ($someEnvStuff) {
$busters[] = new GitTagCacheBuster();
}
$busters[] = new ConstantValueCacheBuster(time()); // fallback
return new MultipleCacheBuster($busters);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment