In memory store

From andresdiegolanda/design-first-ai · View interactive version

In memory store is an AI agent skill from the GitHub repository andresdiegolanda/design-first-ai. ConcurrentHashMap CRUD pattern for the Spring MVC demo. Use when adding a new resource type with in-memory CRUD.

How to use this skill

Skill file

Skill: In-Memory Store (spring-mvc-demo)

Pattern — `ConcurrentHashMap` in the service

@Service
public class [Resource]Service {
    private final Map<UUID, [Resource]> store = new ConcurrentHashMap<>();

    public [Resource] create(Create[Resource]Request request) {
        UUID id = UUID.randomUUID();
        [Resource] item = new [Resource](id, request.name(), ...);
        store.put(id, item);
        return item;
    }

    public [Resource] getById(UUID id) {
        [Resource] item = store.get(id);
        if (item == null) throw new [Resource]NotFoundException(id);
        return item;
    }

    public void delete(UUID id) {
        if (store.remove(id) == null) throw new [Resource]NotFoundException(id);
    }
}

Rules

Design Constraints

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.