Open Yannic opened 6 years ago
Yes, this was the idea that I had in mind when refactoring the code, but I didn't want to make too many changes at the same time (and didn't have an immediate use case for multiple backends).
I'll just inject NewHTTPCache
with a Cache
instead of the cacheDir
, maxSize
arguments, and you should be good to go, right?
I‘m not completely sure that this would be sufficient. httpCache
seems to have a very tight coupling to the stats, which might cause issues in alternative implementations of Cache
(I only have an immediate use case for alternative stogage).
I guess it‘s the best if I investigate some possible solutions and then report the results here.
I have pushed a change that goes into this direction https://github.com/buchgr/bazel-remote/commit/700d941c1a083f87e2b11d4437bf28f931e454f7
sorry for the large commit :(
It would be great if we could add a way to use this cache as a library (i.e. to make integration into existing projects easier). As a side effect, this would mostly implement #12, except the configuration part, and make it easier for folks to implement their own storage mechanism on top of GCS, S3, ...
We would create a new package
httpcache
(to avoid conflicts withnet/http
), which has a functionNew
that returns ahttp.Handler
.(I think
StorageMechanism
will look mostly likeLRU
@nicolov implemented recently).WDYT?