Skip to content

Design Principles

Jeremy Ho edited this page Jun 20, 2025 · 13 revisions

Design Principles

Note

Documentation on this page is still under construction

This page describes the general design principles and guidelines driving the development of the PEACH API.

Table of Contents

Core Features

Note

Behavior in this section is not finalized and may change over time

Design Scope

Note

Behavior in this section is not finalized and may change over time

LRU Cache Strategy

Note

Behavior in this section is not finalized and may change over time

We have implemented an abstraction of a reusable and atomic LRU (Least Recently Used) memory cache for arbitrary database table records. This cache is designed to efficiently store and retrieve singleton records while maintaining a fixed size, automatically evicting the least recently used records when the cache is full, or when a record expires.

Services may opt-in to use this cache for frequently accessed records, allowing for faster retrieval and reduced database load. Under certain conditions, the cache can improve response times significantly, as many lookups are highly repetitive in nature and can benefit from in-memory caching. We have intentionally designed our cacheWrapper pattern to be hot-swappable with the underlying repository logic, allowing us to easily switch between cached and non-cached operations without significant code changes.

---
title: General LRU Cache Strategy
---

graph LR
    DB@{ shape: cyl, label: "Database" }
    EN@{ shape: fr-circ, label: "End" }
    LC@{ shape: st-rect, label: "LRU Cache" }
    LG@{ shape: diamond, label: "LRU Get" }
    LS@{ shape: lin-rect, label: "LRU Set" }
    RP@{ shape: fr-rect, label: "Repository Subroutine" }
    ST@{ shape: sm-circ, label: "Start" }

    ST ==> LG
    LC -.-> LG
    LG == Cache Hit ==> EN
    LG == Cache Miss ==> RP
    LS -.-> LC
    RP ==> EN
    RP --> LS
    RP -.- DB
Loading

Merge Algorithm

Note

Behavior in this section is not finalized and may change over time

Clone this wiki locally