liveBook · Manning

Queue

As explained in Learn Go with Pocket-Sized Projects

First-in-first-out eviction removes entries from a cache in the order in which they were inserted, evicting the oldest entry first.

A queue records insertion order so a bounded cache can evict the oldest entry first. Updating an existing key removes and re-adds it, resetting its position. section 7.4.2

Bounded cache

A cache with capacity three receives keys 1, 2, and 3. Updating key 1 moves it behind key 3; inserting key 4 then evicts key 2, the oldest remaining entry.

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Explains queue operations through cache helpers and tests, while stopping short of general queue abstractions.
Examples
Demonstrates a generic Go cache whose update requeues key 1 and whose fourth insertion evicts key 2.
What it assumes
Assumes familiarity with Go maps and slices while demonstrating queue maintenance inside a generic cache.
What you can do after
Build it from scratch as a chronological slice supporting insertion, arbitrary removal, update requeueing, and oldest-key eviction.
How it connects
Connects queues with caches, slices, maps, TTL expiration, deletion, and updates.

Also explained in

Compare how 24 books explain queue →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.