• Kirill Smelkov's avatar
    zodb/go: In-RAM client cache · 7233b4c0
    Kirill Smelkov authored
    The cache is needed so that we can provide IStorage.Prefetch
    functionality generally wrapped on top of a storage driver: when an
    object is loaded, the loading itself consists of steps:
    
    1. start loading object into cache,
    2. wait for the loading to complete.
    
    This way Prefetch is naturally only "1" - start loading object into
    cache but do not wait for the loading to be complete. Go's goroutines
    naturally help here where we can spawn every such loading into its own
    goroutine instead of explicitly programming loading in terms of a state
    machine.
    
    Since this cache is mainly needed for Prefetch to work, not to actually
    cache data (though it works as cache for repeating access too), the goal
    when writing it was to add minimal overhead for "data-not-yet-in-cache"
    case. Current state we are not completely there yet but the latency is
    acceptable - depending on the workload the cache layer adds ~
    
    	0.5 - 1 - 3µs
    
    to loading times.
    7233b4c0
cache.go 17.8 KB