Add option to locally enforce payload size limit #515
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This creates a new Memcached option item_size_limit to locally enforce a maximum payload size. The intent behind use of this option is to mirror the Memcached server maximum item size configuration in PHP Memcached client configuration, permitting client optimization by avoiding issuance over the network of large payloads which are destined to be rejected by the server.
Payload size is determined after compression, when applicable, and it is in consideration of payload compression that the option is being introduced at the extension level. PHP callers cannot themselves perfectly enforce a payload size limit without the undue burden of mirroring compression of the payload. Alternatively, placement within libmemcached, while perhaps also desirable, does not permit PHP application-level configuration.
The Memcached INI has been extended to support the option via "memcached.item_size_limit" as has Memcached::setOption(), which uses the newly-added Memcached::OPT_ITEM_SIZE_LIMIT. No limit is enforced by default, and a value of "0" implies no limit.
The existing MEMCACHED_E2BIG error code is used, which results in the error message "ITEM TOO BIG", such that no behavior change is intended in activation of the new validation pathways to the current client response when the server rejects the payload due to size.
https://github.com/memcached/memcached/wiki/ReleaseNotes142#configurable-maximum-item-size