Skip to content

Conversation

raulk
Copy link
Contributor

@raulk raulk commented Nov 15, 2020

(on top of #92 -- merge that first!)

Fixes #91.

This commit introduces two methods GetFn and PeekFn. These methods
provide zero-copy access to cache entries, avoiding allocs unless
absolutely necessary.

They accept a function, and call it with a slice over the current
underlying value of the key in memory. The slice is constrained
in length and capacity. The RingBuf struct has been augmented with
a Slice() method to support these operations.

The only case where these variants allocate is when the value wraps
around the ring buffer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

benchmarks are incorrect
1 participant