json-vat
json-vat copied to clipboard
Rewrite to cleanly separate caching concern
With my findings in last PR https://github.com/adamcooke/json-vat/pull/7 caching invalidation needs more complex handling so I've decided to do a significant rewrite to extract Configuration
, PlainClient
and CachedClient
from the procedural code inside the JSONVAT module as the resolving of the cache invalidation would add another bunch of IFs.
At first I've tried composition, but it leads to me to really complex solution which felt like overengineering so I ended-up with old fashioned inheritance approach.
The code should be compatible with the original API. But I've decided to deprecate configuration writers since I've added configure
and configuration
methods.
Now you can also use the client classes directly
client = JSONVAT::CachedClient.new("my.host", MyCacheBackend.new)
JSONVAT.configure do |config|
config.client = JSONVAT::CachedClient.new("my.host", MyCacheBackend.new)
end
The code works I've run our in-app adapter tests against it successfully, but I feel it would be handy to add some tests or at least more documentation. So it should be considered as still in WIP.