64 bit atomic operations and shared cache memory usage

First thing that irked me about the cache implementation: having a "max memory usage" counter per cache is hardly useful at all, because your total memory usage depends on how many repositories you have open at the same time.

I've implemented some basic atomic64 ops here, and made the memory usage for the cache shared across threads. Now caches will evict when the global memory limit is reached, possibly leaving space for other caches.