-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to locally enforce payload size limit (#515)
Add a configuration option to enforce an item size limit on the client side. This avoids sending large items over the wire and getting rejected by the server which can cause delays. The default is 0 for no limit. The same error code RES_E2BIG is used for the client side limit as for the server side limit.
- Loading branch information
Showing
8 changed files
with
151 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--TEST-- | ||
set data exceeding size limit | ||
--SKIPIF-- | ||
<?php include "skipif.inc";?> | ||
--FILE-- | ||
<?php | ||
include dirname (__FILE__) . '/config.inc'; | ||
$m = memc_get_instance (array ( | ||
Memcached::OPT_ITEM_SIZE_LIMIT => 100, | ||
)); | ||
|
||
$m->delete('cas_e2big_test'); | ||
|
||
$m->set('cas_e2big_test', 'hello'); | ||
$result = $m->get('cas_e2big_test', null, Memcached::GET_EXTENDED); | ||
var_dump(is_array($result) && isset($result['cas']) && isset($result['value']) && $result['value'] == 'hello'); | ||
|
||
$value = str_repeat('a large payload', 1024 * 1024); | ||
|
||
var_dump($m->cas($result['cas'], 'cas_e2big_test', $value, 360)); | ||
var_dump($m->getResultCode() == Memcached::RES_E2BIG); | ||
var_dump($m->getResultMessage() == 'ITEM TOO BIG'); | ||
var_dump($m->get('cas_e2big_test') == 'hello'); | ||
var_dump($m->getResultCode() == Memcached::RES_SUCCESS); | ||
?> | ||
--EXPECT-- | ||
bool(true) | ||
bool(false) | ||
bool(true) | ||
bool(true) | ||
bool(true) | ||
bool(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
set data exceeding size limit | ||
--SKIPIF-- | ||
<?php include "skipif.inc";?> | ||
--FILE-- | ||
<?php | ||
include dirname (__FILE__) . '/config.inc'; | ||
$m = memc_get_instance (array ( | ||
Memcached::OPT_ITEM_SIZE_LIMIT => 100, | ||
)); | ||
|
||
$m->delete('set_large_e2big_test'); | ||
|
||
$value = str_repeat('a large payload', 1024 * 1024); | ||
|
||
var_dump($m->set('set_large_e2big_test', $value)); | ||
var_dump($m->getResultCode() == Memcached::RES_E2BIG); | ||
var_dump($m->getResultMessage() == 'ITEM TOO BIG'); | ||
var_dump($m->get('set_large_e2big_test') === false); | ||
var_dump($m->getResultCode() == Memcached::RES_NOTFOUND); | ||
?> | ||
--EXPECT-- | ||
bool(false) | ||
bool(true) | ||
bool(true) | ||
bool(true) | ||
bool(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters