{"action":"created","issue":{"url":"https://api.github.com/repos/michaelfairley/method_decorators/issues/21","repository_url":"https://api.github.com/repos/michaelfairley/method_decorators","labels_url":"https://api.github.com/repos/michaelfairley/method_decorators/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/michaelfairley/method_decorators/issues/21/comments","events_url":"https://api.github.com/repos/michaelfairley/method_decorators/issues/21/events","html_url":"https://github.com/michaelfairley/method_decorators/issues/21","id":133421286,"number":21,"title":"Memorize Decorator","user":{"login":"ahilmer","id":4171011,"avatar_url":"https://avatars.githubusercontent.com/u/4171011?v=3","gravatar_id":"","url":"https://api.github.com/users/ahilmer","html_url":"https://github.com/ahilmer","followers_url":"https://api.github.com/users/ahilmer/followers","following_url":"https://api.github.com/users/ahilmer/following{/other_user}","gists_url":"https://api.github.com/users/ahilmer/gists{/gist_id}","starred_url":"https://api.github.com/users/ahilmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahilmer/subscriptions","organizations_url":"https://api.github.com/users/ahilmer/orgs","repos_url":"https://api.github.com/users/ahilmer/repos","events_url":"https://api.github.com/users/ahilmer/events{/privacy}","received_events_url":"https://api.github.com/users/ahilmer/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-13T10:49:51Z","updated_at":"2016-02-14T09:12:37Z","closed_at":"2016-02-14T01:26:07Z","body":"Hi,\r\n\r\nwhy does the memorize decorator create a new random instance variable `@memo_ivar = \"@_memoize_cache#{rand(10**10)}\" `?\r\n\r\nYou could just create a empty cache like this:\r\n\r\n`\r\n\r\n    def initialize\r\n\t  @cache = {}\r\n    end\r\n\r\n    def call(orig, this, *args, &blk)\r\n      return @cache[args] if @cache.has_key?(args)\r\n      @cache[args] = orig.call(*args, &blk)\r\n    end\r\n\r\n`\r\n\r\nAre there any reasons?\r\n\r\nBest regard,\r\nAndi"},"comment":{"url":"https://api.github.com/repos/michaelfairley/method_decorators/issues/comments/183857972","html_url":"https://github.com/michaelfairley/method_decorators/issues/21#issuecomment-183857972","issue_url":"https://api.github.com/repos/michaelfairley/method_decorators/issues/21","id":183857972,"user":{"login":"ahilmer","id":4171011,"avatar_url":"https://avatars.githubusercontent.com/u/4171011?v=3","gravatar_id":"","url":"https://api.github.com/users/ahilmer","html_url":"https://github.com/ahilmer","followers_url":"https://api.github.com/users/ahilmer/followers","following_url":"https://api.github.com/users/ahilmer/following{/other_user}","gists_url":"https://api.github.com/users/ahilmer/gists{/gist_id}","starred_url":"https://api.github.com/users/ahilmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahilmer/subscriptions","organizations_url":"https://api.github.com/users/ahilmer/orgs","repos_url":"https://api.github.com/users/ahilmer/repos","events_url":"https://api.github.com/users/ahilmer/events{/privacy}","received_events_url":"https://api.github.com/users/ahilmer/received_events","type":"User","site_admin":false},"created_at":"2016-02-14T09:12:37Z","updated_at":"2016-02-14T09:12:37Z","body":"Only one single instance of `Memoize`? I think there is always a new instance of `Memoize ` created when a method gets decorated. So every single instance of `Memoize` can have its own cache variable. And there is no more  need to store the cache on the instance which gets decorated?"}}