You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As there were a bunch of complaints regarding the memory_limit option and since it is not properly working anyways, I'd propose replacing the memory_limit option with a max_items option instead.
Background
The calculation of free and used memory within PHP at runtime is not really working. Especially since there is no way (at least not in the way it is implemented right now) to calculate the only consumed memory from within the memory adapter.
Having max_items option allows users to either limit the cache to a specific amount of entries (to prevent memory from somehow overflowing - ofc that only works if a proper value is chosen) or just allows unlimited cache items.
Considerations
Users will have to modify their options to allow a certain amount/unlimited cache items in the memory adapter rather than defining a memory_limit.
Proposal(s)
Replace memory_limit with max_items. The adapter is not able to handle memory_limit in a meaningful way. Memory can be consumed outside of the memory adapter and lead to overflows as well and thus, I do not see a reason to have any memory limit handling in the memory adapter. Consumers should be aware that the memory adapter works the same way as a property cache, there won't be any "auto-free memory when memory_limit is close to overflow" and thus.
Having an option to limit cache items to a certain amount of items might help preventing an actual overflow from a count perspective but does not respect the cache item size in any way. But I guess thats absolutely okay and thats what people used to work with in symfony cache as well.
Considering that the memory_limit option effectively can't work (?), could the relevant code be removed without breaking BC, and, could the max_items option be introduced in 2.x thereby leaving only the removal of the memory_limit option in 3.x
RFC
Goal
As there were a bunch of complaints regarding the
memory_limit
option and since it is not properly working anyways, I'd propose replacing thememory_limit
option with amax_items
option instead.Background
The calculation of free and used memory within PHP at runtime is not really working. Especially since there is no way (at least not in the way it is implemented right now) to calculate the only consumed memory from within the memory adapter.
Having
max_items
option allows users to either limit the cache to a specific amount of entries (to prevent memory from somehow overflowing - ofc that only works if a proper value is chosen) or just allows unlimited cache items.Considerations
Users will have to modify their options to allow a certain amount/unlimited cache items in the memory adapter rather than defining a
memory_limit
.Proposal(s)
Replace
memory_limit
withmax_items
. The adapter is not able to handlememory_limit
in a meaningful way. Memory can be consumed outside of the memory adapter and lead to overflows as well and thus, I do not see a reason to have any memory limit handling in the memory adapter. Consumers should be aware that the memory adapter works the same way as a property cache, there won't be any "auto-free memory when memory_limit is close to overflow" and thus.Having an option to limit cache items to a certain amount of items might help preventing an actual overflow from a count perspective but does not respect the cache item size in any way. But I guess thats absolutely okay and thats what people used to work with in symfony cache as well.
Appendix
Ref: https://symfony.com/doc/current/components/cache/adapters/array_cache_adapter.html
Ref: #56
Ref: #54
Ref: #5
Ref: #11
Ref: #7
The text was updated successfully, but these errors were encountered: