Readablewiki

Identity map pattern

Content sourced from Wikipedia, licensed under CC BY-SA 3.0.

Identity map pattern is a database access technique that keeps a private in-memory cache of objects loaded during a request or session. When you need an object, the map checks the cache first. If the object is already loaded, it returns the cached instance. If not, it loads it from the database, stores it in the cache, and returns it. This prevents loading the same data multiple times and speeds things up. It’s similar to lazy loading: data is loaded on demand and then reused. There are several variants of identity maps, such as per-session, per-request, or per-transaction.


This page was last edited on 3 February 2026, at 11:17 (CET).