Created
April 15, 2019 18:50
-
-
Save stefpe/af0c9766835230740fff17a7f50e3593 to your computer and use it in GitHub Desktop.
func_get_args hash cache key example
This file contains hidden or 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 | |
| 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