Skip to content

Instantly share code, notes, and snippets.

View zhandao's full-sized avatar
🎯
(๑ ̀ㅅ ́๑)

阙溪台 zhandao

🎯
(๑ ̀ㅅ ́๑)
View GitHub Profile
@zhandao
zhandao / memory_take.md
Last active November 10, 2023 07:05
[Ruby on Rails] Let ActiveRecord take record instance directly from memory (cached)

inspired by [https://sourcediving.com/this-rails-cache-is-not-your-friend-512871c138aa]

Let ActiveRecord take record instance directly from memory (cached), instead of instantiate from result set, for reducing memory allocation times and time.

It is very simple implementation of Identity Map.

It is suitable for reading is much more frequent than updating, like hot posts (preferably non editable).