dcrd/lru
Dave Collins ad02d8f300
multi: Go 1.19 doc comment formatting.
This modifies the entire repository to use the new formatting of doc
comments in the upcoming Go 1.19 release.

The primary motivating factors for this are:

- Builds check that files are formatted per gofmt and that will no
  longer be true as of Go 1.19 without these changes
- Separating all the updates into a single commit ensures these
  documentation only formatting changes do not clutter up diffs that
  actually change code

For the most part, the changes are just the automated changes suggested
by the Go 1.19 version of gofmt, but there are also a few cases where
the comments were reworded a bit to play nicely with the new formatting
requirements.

For example, the new version of gofmt reformats and collapses nested
lists where as the existing version does not.  Thus, instances of nested
lists have been changed to either eliminate them or use mixed markers
which produce expect results.
2022-07-30 04:08:58 -05:00
..
cache_test.go multi: Correct typos. 2019-08-22 10:20:03 -05:00
cache.go multi: Address a bunch of lint issues. 2019-12-30 13:54:41 -06:00
doc.go multi: Go 1.19 doc comment formatting. 2022-07-30 04:08:58 -05:00
example_test.go lru: add kv cache. 2019-11-12 00:00:06 -06:00
go.mod multi: Support module graph prune and lazy load. 2022-03-25 07:20:01 -05:00
kv_test.go lru: add kv cache. 2019-11-12 00:00:06 -06:00
kv.go lru: Fix lookup race on small caches. 2020-11-09 15:32:22 -06:00
README.md multi: Update README.md files for go modules. 2021-01-22 14:39:23 -06:00

lru

Build Status ISC License Doc

Package lru implements generic least-recently-used caches with near O(1) perf.

LRU Cache

A least-recently-used (LRU) cache is a cache that holds a limited number of items with an eviction policy such that when the capacity of the cache is exceeded, the least-recently-used item is automatically removed when inserting a new item. The meaning of used in this implementation is either accessing the item via a lookup or adding the item into the cache, including when the item already exists.

External Use

This package has intentionally been designed so it can be used as a standalone package for any projects needing to make use of well-tested and concurrent safe least-recently-used caches with near O(1) performance characteristics for lookups, inserts, and deletions.

Installation and Updating

This package is part of the github.com/decred/dcrd/lru module. Use the standard go tooling for working with modules to incorporate it.

Examples

  • Basic Cache Usage Demonstrates creating a new cache instance, inserting items into the cache, causing an eviction of the least-recently-used item, and removing an item.

  • Basic KV Cache Usage Demonstrates creating a new k/v cache instance, inserting items into the cache, causing an eviction of the least-recently-used item, and removing an item.

License

Package lru is licensed under the copyfree ISC License.