Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
look up rights metadata for rights statements faster #705
We were using , from QA gem.
This ended up re-loading YAML from disk on every call. Either the QA code needs caching
Before PR, we were looking up stuff from .yml file via CC/QA with calls like this:
Profiling suggested that there might have been a lot of time spent in
Looking at stack traces and QA code (we are currently using qa 0.11.1), I first noticed this:
At first I considered adding caching here. But adding caching to FileBasedAuthority only works if you are re-using a file-based authority instance. The API we are using started with
It's possible there is some other API in CC or QA we could use that would re-use a FileBasedAuthority object instead of creating a new one each time. This stuff isn't documented very well, I'm not certain. Even if it were, FileBasedAuthority is still not caching.
I decided QA was just not intended for this use case (or any use case but auto-completing an edit field via an AJAX request), doesn't neccesarily have the API or semantics to support it, and rather than try to figure it out and/or hack it to do so -- reading a YAML file and pulling data out of it is not a complicated thing, it made sense just to spend the 45 minutes writing the couple dozen straightforward lines of code to just read the YAML file and cache it.