{"action":"created","issue":{"url":"https://api.github.com/repos/estately/rets/issues/134","labels_url":"https://api.github.com/repos/estately/rets/issues/134/labels{/name}","comments_url":"https://api.github.com/repos/estately/rets/issues/134/comments","events_url":"https://api.github.com/repos/estately/rets/issues/134/events","html_url":"https://github.com/estately/rets/pull/134","id":88114417,"number":134,"title":":metadata_cache option for easier metadata caching","user":{"login":"wconrad","id":1935752,"avatar_url":"https://avatars.githubusercontent.com/u/1935752?v=3","gravatar_id":"","url":"https://api.github.com/users/wconrad","html_url":"https://github.com/wconrad","followers_url":"https://api.github.com/users/wconrad/followers","following_url":"https://api.github.com/users/wconrad/following{/other_user}","gists_url":"https://api.github.com/users/wconrad/gists{/gist_id}","starred_url":"https://api.github.com/users/wconrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wconrad/subscriptions","organizations_url":"https://api.github.com/users/wconrad/orgs","repos_url":"https://api.github.com/users/wconrad/repos","events_url":"https://api.github.com/users/wconrad/events{/privacy}","received_events_url":"https://api.github.com/users/wconrad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-06-14T03:56:15Z","updated_at":"2015-06-22T16:46:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/estately/rets/pulls/134","html_url":"https://github.com/estately/rets/pull/134","diff_url":"https://github.com/estately/rets/pull/134.diff","patch_url":"https://github.com/estately/rets/pull/134.patch"},"body":"This is an attempt to make metadata caching easier and more efficient.  From the README:\r\n\r\n-----\r\n\r\nMetadata, which is loaded when a client is first started, can be slow\r\nto fetch.  To avoid the cost of fetching metadata every time the\r\nclient is started, metadata can be cached.\r\n\r\nTo cache metadata, pass the :metadata_cache option to the client when\r\nyou start it.  The library comes with a predefined metadata cache that\r\npersists the metadata to a file.  It is created with the path to which\r\nthe cached metadata should be written:\r\n\r\n    metadata_cache = Rets::Metadata::FileCache.new(\"/tmp/metadata\")\r\n\r\nWhen you create the RETS client, pass it the metadata cache:\r\n\r\n    client = Rets::Client.new(\r\n      login_url: @login_url,\r\n      # ... etc\r\n      metadata_cache: metadata_cache\r\n    )\r\n\r\nIf you want to persist to something other than a file, create your own\r\nmetadata cache object and pass it in.  It should have the same interface\r\nas the built-in FileCache:\r\n\r\n    class MyMetadataCache\r\n\r\n      # Save the metadata.\r\n      def save(metadata)\r\n      end\r\n\r\n      # Load the metadata.  Return nil if it could not be loaded.\r\n      def load\r\n      end\r\n\r\n    end\r\n\r\nSee the source for Rets::Metadata::FileCache for more.\r\n\r\n-----\r\n\r\n* With this PR, the user does not need to worry about when the metadata should be persisted.  The cache's #save method is only called when the metadata has been fetched from the feed due to a missing or outdated cache.\r\n\r\n* The user no longer needs to set the logger on unmarshalled metadata--the client does that.\r\n\r\n* This makes it easy to substitute one persistence mechanism (say, database) for another.\r\n\r\n* The existing :metadata option still works.  It takes precedence over the new :metadata_cache option.\r\n\r\nI've written no tests for this (although it seems to work fine).  I wanted to find out whether you agree with this approach before trying to write tests."},"comment":{"url":"https://api.github.com/repos/estately/rets/issues/comments/114175791","html_url":"https://github.com/estately/rets/pull/134#issuecomment-114175791","issue_url":"https://api.github.com/repos/estately/rets/issues/134","id":114175791,"user":{"login":"summera","id":2474416,"avatar_url":"https://avatars.githubusercontent.com/u/2474416?v=3","gravatar_id":"","url":"https://api.github.com/users/summera","html_url":"https://github.com/summera","followers_url":"https://api.github.com/users/summera/followers","following_url":"https://api.github.com/users/summera/following{/other_user}","gists_url":"https://api.github.com/users/summera/gists{/gist_id}","starred_url":"https://api.github.com/users/summera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/summera/subscriptions","organizations_url":"https://api.github.com/users/summera/orgs","repos_url":"https://api.github.com/users/summera/repos","events_url":"https://api.github.com/users/summera/events{/privacy}","received_events_url":"https://api.github.com/users/summera/received_events","type":"User","site_admin":false},"created_at":"2015-06-22T16:46:40Z","updated_at":"2015-06-22T16:46:40Z","body":"@wconrad haha no worries! Fairly new to me as well.\r\n\r\n@hfaulds @dougcole @tcrayford  would you guys happen to know how often the Metadata for an individual MLS changes (become out of date) and what usually changes within the metadata?"}}