Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to locally enforce payload size limit #515

Merged
merged 3 commits into from
Apr 27, 2023

Conversation

rposky
Copy link
Contributor

@rposky rposky commented Jun 13, 2022

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

…no limit.

Wiring size limit check into payload construction, generating ITEM TOO BIG error in excess of limit.
@sodabrew
Copy link
Contributor

sodabrew commented Jun 13, 2022

Looks nice! I think the smaller functions could be rolled together since they're only used once.

Update: approved the CI run and all tests pass. Nice work!

@sodabrew sodabrew merged commit e39a2e6 into php-memcached-dev:master Apr 27, 2023
m6w6 added a commit that referenced this pull request Sep 26, 2024
- Add #515 option to locally enforce payload size limit
- Add #539 zstd support
- Add #540 compression_level option
- Mark password as a sensitive param for PHP 8.2
- Fix Windows PHP 8 compatibility
- Fix #518 Windows msgpack support
- Fix #522 signed integer overflow
- Fix #523 incorrect PHP reflection type for Memcached::cas $cas_token
- Fix #546 don't check key automatically, unless client-side verify_key is enabled
- Fix #555 incompatible pointer types (32-bit)
m6w6 added a commit that referenced this pull request Oct 4, 2024
    - Add #515 option to locally enforce payload size limit
    - Add #539 zstd support
    - Add #540 compression_level option
    - Mark password as a sensitive param for PHP 8.2
    - Fix Windows PHP 8 compatibility
    - Fix #518 Windows msgpack support
    - Fix #522 signed integer overflow
    - Fix #523 incorrect PHP reflection type for Memcached::cas $cas_token
    - Fix #546 don't check key automatically, unless client-side verify_key is enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants