Skip to content

Instantly share code, notes, and snippets.

@stefpe
Created April 15, 2019 18:50
Show Gist options
  • Select an option

  • Save stefpe/af0c9766835230740fff17a7f50e3593 to your computer and use it in GitHub Desktop.

Select an option

Save stefpe/af0c9766835230740fff17a7f50e3593 to your computer and use it in GitHub Desktop.
func_get_args hash cache key example
<?php
function getProductData(int $productId, string ... $predicates)
{
$args = func_get_args();
$hash = '';
foreach ($args as $arg){
$hash .= (string)($arg);
}
$cacheKey = md5($hash);
//@todo -> fetch data form external service on cache miss and update the cache
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment