{"action":"opened","issue":{"url":"https://api.github.com/repos/woocommerce/woocommerce/issues/15524","repository_url":"https://api.github.com/repos/woocommerce/woocommerce","labels_url":"https://api.github.com/repos/woocommerce/woocommerce/issues/15524/labels{/name}","comments_url":"https://api.github.com/repos/woocommerce/woocommerce/issues/15524/comments","events_url":"https://api.github.com/repos/woocommerce/woocommerce/issues/15524/events","html_url":"https://github.com/woocommerce/woocommerce/issues/15524","id":234629395,"number":15524,"title":"Improve caching of wc_customer_bought_product","user":{"login":"claudiulodro","id":7317227,"avatar_url":"https://avatars0.githubusercontent.com/u/7317227?v=3","gravatar_id":"","url":"https://api.github.com/users/claudiulodro","html_url":"https://github.com/claudiulodro","followers_url":"https://api.github.com/users/claudiulodro/followers","following_url":"https://api.github.com/users/claudiulodro/following{/other_user}","gists_url":"https://api.github.com/users/claudiulodro/gists{/gist_id}","starred_url":"https://api.github.com/users/claudiulodro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudiulodro/subscriptions","organizations_url":"https://api.github.com/users/claudiulodro/orgs","repos_url":"https://api.github.com/users/claudiulodro/repos","events_url":"https://api.github.com/users/claudiulodro/events{/privacy}","received_events_url":"https://api.github.com/users/claudiulodro/received_events","type":"User","site_admin":false},"labels":[{"id":472334370,"url":"https://api.github.com/repos/woocommerce/woocommerce/labels/Focus:%20Performance","name":"Focus: Performance","color":"fef2c0","default":false},{"id":477739353,"url":"https://api.github.com/repos/woocommerce/woocommerce/labels/Good%20first%20patch","name":"Good first patch","color":"f5f5f5","default":false},{"id":156591,"url":"https://api.github.com/repos/woocommerce/woocommerce/labels/Type:%20Refactor","name":"Type: Refactor","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-06-08T19:18:54Z","updated_at":"2017-06-08T19:18:54Z","closed_at":null,"body":"[`wc_customer_bought_product`](https://github.com/woocommerce/woocommerce/blob/master/includes/wc-user-functions.php#L197) can be called three different ways that get the same results:\r\n\r\n`wc_customer_bought_product( 'email@example.com', 12, 50 );`\r\n`wc_customer_bought_product( '', 12, 50 );`\r\n`wc_customer_bought_product( 'email@example.com', 0, 50 );`\r\n\r\nThe function calculates the transient name using the input email and customer id:\r\n`$transient_name = 'wc_cbp_' . md5( $customer_email . $user_id . WC_Cache_Helper::get_transient_version( 'orders' ) );`\r\n\r\nFor each of the three ways of calling `wc_customer_bought_product` above, there will be a cache miss, a new query will be run, and a new transient will be cached. \r\n\r\nSince the results will be the same for all three calls, they should ideally all cache to the same place."}}
{"actor":{"display_login":"claudiulodro"}}