Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce GetFn and PeekFn methods, for zero-copy access. #1

Merged
merged 1 commit into from
Nov 15, 2020

Conversation

raulk
Copy link
Owner

@raulk raulk commented Nov 15, 2020

See coocood#92.

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.
@raulk raulk merged commit bf6f612 into master Nov 15, 2020
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.

1 participant