From kotlin-patterns
Apply when creating, refactoring, changing, planning (plan mode) or reviewing repository methods that save entities with optimistic locking.
How this skill is triggered — by the user, by Claude, or both
Slash command
/kotlin-patterns:applying-optimistic-lockingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Prevent lost updates when multiple processes modify the same entity concurrently. Each entity carries a version field that is checked during updates - if the version has changed since the entity was read, the update is rejected.
Prevent lost updates when multiple processes modify the same entity concurrently. Each entity carries a version field that is checked during updates - if the version has changed since the entity was read, the update is rejected.
version field (integer, starting at 0)WHERE version = ? conditionOptimisticLockingExceptionDO:
version: Long field to entities that can be concurrently modifiedWHERE version = ? in UPDATE/INSERT ON CONFLICT SQL statementsOptimisticLockingException when zero rows are affectedversion = version + 1 or version = EXCLUDED.version + 1)DON'T:
Please use always these examples as reference: examples.md
npx claudepluginhub allousas/claude-code-plugins --plugin kotlin-patternsImplements optimistic locking via version columns, timestamps, or compare-and-swap to handle concurrent writes without database locks. Includes conflict detection and retry logic for web APIs and edit-and-save workflows.
Provides knowledge base on consistency patterns including strong vs eventual consistency, idempotency keys, optimistic/pessimistic locking, conflict resolution, and sagas for auditing distributed PHP applications.
Handles Doctrine transaction management including ORM 3 wrapInTransaction, optimistic/pessimistic locking, flush strategies, and transaction boundaries.