Skip to content

Add caching #118

@nicolas-brousse

Description

@nicolas-brousse

Hi!

We currently have some issues with usage of VIES API on one of our project because of their API have some issues.
It's not related to valvat gem which does its work correctly. But I was thinking of having some little cache to avoid calling too many time VIES API when not required.

Since VAT validity does not change this often, I guess 1 or few hour of cache on a VAT number may not be risky.

I will take time to do a pull request, but I prefer to discuss here before doing some code.

One thing to have in mind is that this gem is not fully related to Rails and should work without it. So Valvat::Lookup objects may not be able to use Rails.cache (at least directly).

So I've thing about 2 ways of doing caching:

  1. On lookup
    Having a generic cache object (ex: https://github.com/alexreisner/geocoder#caching) that could be use as proxy for Rails.cache.
  2. On validation only
    Add a cache: true (or cache: 2.hours) option in validator that may use Rails.cache.

What do you think about it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions