proxy.golang.org : github.com/pborman/cachedrander
Package cachedrander provides a reader designed to cache random data for the creation of random UUIDs. Using rand.Reader as the source of random data (the default for github.com/google/uuid) requires a mutex operation per newly minted version 4 (random) UUID. This package typically only requires a single atomic.AddUint64 per newly minted UUID. This package works by having two pages of cached random data. The first page is read when the CachedReader is created. Once that page has been exhausted Read calls will block on a mutex while the second page is being loaded. This package has a theoretical race condition: Caller A reads the index of its data in the current page and is prempted. Prior to resuming a sufficent number of calls to Read are made to exhaust the current page and the next loaded page. It is now possible for caller A to return the same data as another caller. to mitigate this condition the CachedReader should use a sufficiently large cache that the probability of this happening is essentially 0.
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/pborman/cachedrander
License: Apache-2.0
Latest release: almost 6 years ago
First release: almost 6 years ago
Namespace: github.com/pborman
Stars: 2 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: about 2 months ago