{"action":"created","issue":{"url":"https://api.github.com/repos/freeside/Freeside/issues/38","labels_url":"https://api.github.com/repos/freeside/Freeside/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/freeside/Freeside/issues/38/comments","events_url":"https://api.github.com/repos/freeside/Freeside/issues/38/events","html_url":"https://github.com/freeside/Freeside/pull/38","id":57388241,"number":38,"title":"Cache the FS::Conf info per page load, for performance.","user":{"login":"oaxlin","id":2235679,"avatar_url":"https://avatars.githubusercontent.com/u/2235679?v=3","gravatar_id":"","url":"https://api.github.com/users/oaxlin","html_url":"https://github.com/oaxlin","followers_url":"https://api.github.com/users/oaxlin/followers","following_url":"https://api.github.com/users/oaxlin/following{/other_user}","gists_url":"https://api.github.com/users/oaxlin/gists{/gist_id}","starred_url":"https://api.github.com/users/oaxlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oaxlin/subscriptions","organizations_url":"https://api.github.com/users/oaxlin/orgs","repos_url":"https://api.github.com/users/oaxlin/repos","events_url":"https://api.github.com/users/oaxlin/events{/privacy}","received_events_url":"https://api.github.com/users/oaxlin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-11T22:34:09Z","updated_at":"2015-02-13T06:02:45Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/freeside/Freeside/pulls/38","html_url":"https://github.com/freeside/Freeside/pull/38","diff_url":"https://github.com/freeside/Freeside/pull/38.diff","patch_url":"https://github.com/freeside/Freeside/pull/38.patch"},"body":"This pull request adds in a caching layer to FS::Conf that is reset upon every page load.  We reset the cache in FS::UID::myconnect along with the database connection.  This prevents any stale data from being kept, yet gives a significant improvement in performance of the FS::Conf system for larger pages and fsqueue tasks.\r\n\r\nIn testing if we called a FS::Conf->config() 1000 times the old config method would take roughly 1.3 seconds.  And this is under ideal circumstances where the DB is localhost.  If the DB were elsewhere you could see even slower results.\r\n\r\nWith the new caching system, the same 1000 calls only took 0.00958 seconds.  The new cache system is also more tolerant of a DB being remote since it makes less DB queries.\r\n\r\nI did some data collection on how many times FS::Conf->config() is called per page view.  For trivial pages roughly 50 calls are made, for a customer with 18 products there were a few hundred calls... customers with more lengthy order histories, or dozens of products could easily have a few thousand calls to FS::Conf->config() for a single page load.  The end result is that this update could potentially save several seconds of load time per page."},"comment":{"url":"https://api.github.com/repos/freeside/Freeside/issues/comments/74209300","html_url":"https://github.com/freeside/Freeside/pull/38#issuecomment-74209300","issue_url":"https://api.github.com/repos/freeside/Freeside/issues/38","id":74209300,"user":{"login":"oaxlin","id":2235679,"avatar_url":"https://avatars.githubusercontent.com/u/2235679?v=3","gravatar_id":"","url":"https://api.github.com/users/oaxlin","html_url":"https://github.com/oaxlin","followers_url":"https://api.github.com/users/oaxlin/followers","following_url":"https://api.github.com/users/oaxlin/following{/other_user}","gists_url":"https://api.github.com/users/oaxlin/gists{/gist_id}","starred_url":"https://api.github.com/users/oaxlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oaxlin/subscriptions","organizations_url":"https://api.github.com/users/oaxlin/orgs","repos_url":"https://api.github.com/users/oaxlin/repos","events_url":"https://api.github.com/users/oaxlin/events{/privacy}","received_events_url":"https://api.github.com/users/oaxlin/received_events","type":"User","site_admin":false},"created_at":"2015-02-13T06:02:45Z","updated_at":"2015-02-13T06:02:45Z","body":"So 'opt-in' has nothing to do with the user/admin preference, and more to do with the fact that the codebase itself is safe to cache.\r\n\r\nI'll update the pull request over the weekend with that in mind."}}