Changeset e68fca
- Timestamp:
- 01/13/08 14:34:25 (4 years ago)
- Branches:
- master, ketama-compat
- Children:
- dad4cc
- Parents:
- ccd211
- git-author:
- Tomash Brechko <tomash.brechko@…> (01/13/08 14:34:25)
- git-committer:
- Tomash Brechko <tomash.brechko@…> (01/13/08 14:34:25)
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Changes
r823293 re68fca 31 31 script/compare.pl was removed. Instead script/benchmark.pl 32 32 takes an optional last argument "compare". 33 34 New 'utf8' parameter for constructor. 33 35 34 36 -
MANIFEST
r823293 re68fca 18 18 t/pod-coverage.t 19 19 t/pod.t 20 t/utf8.t 20 21 lib/Cache/Memcached/Fast.pm 21 22 src/Makefile.PL -
TODO
rccd211 re68fca 22 22 23 23 - Add test for noreply, do not list it in MANIFEST. 24 25 - utf8 => 1 (in utf8 branch).26 24 27 25 - tainted_in, tainted_out parameters. -
lib/Cache/Memcached/Fast.pm
rabe4dc re68fca 41 41 ketama_points => 150, 42 42 nowait => 1, 43 utf8 => ($^V >= 5.008001 ? 1 : 0), 43 44 }); 44 45 … … 130 131 use constant F_STORABLE => 0x1; 131 132 use constant F_COMPRESS => 0x2; 133 use constant F_UTF8 => 0x4; 132 134 133 135 … … 166 168 use fields qw( 167 169 _xs servers 168 compress_threshold compress_ratio compress_methods 170 compress_threshold compress_ratio compress_methods utf8 169 171 ); 170 172 … … 392 394 393 395 396 =item I<utf8> (B<experimental, Perl 5.8.1 and later only>) 397 398 utf8 => 1 399 (default: disabled) 400 401 The value is a boolean which enables (true) or disables (false) the 402 conversion of Perl character strings to octet sequences in UTF-8 403 encoding on store, and the reverse conversion on fetch (when the 404 retrieved data is marked as being UTF-8 octet sequence). See 405 L<perlunicode|perlunicode>. 406 407 394 408 =back 395 409 … … 415 429 } 416 430 431 if ($conf->{utf8}) { 432 if ($^V >= 5.008001) { 433 $self->{utf8} = 1; 434 } else { 435 carp "'utf8' may be enabled only for Perl >= 5.8.1, disabled"; 436 } 437 } 438 417 439 $self->{_xs} = new Cache::Memcached::Fast::_xs($conf); 418 440 … … 473 495 $flags |= F_STORABLE; 474 496 } else { 475 $val_ref = \$_[0]; 497 if ($self->{utf8} and utf8::is_utf8($_[0])) { 498 # We have to copy the value because we will modify it in place. 499 my $octets = $_[0]; 500 utf8::encode($octets); 501 $flags |= F_UTF8; 502 $val_ref = \$octets; 503 } else { 504 $val_ref = \$_[0]; 505 } 476 506 } 477 507 … … 519 549 }; 520 550 return if $@; 551 } elsif ($_[1] & F_UTF8 and $self->{utf8}) { 552 return unless utf8::decode(${$_[0]}); 521 553 } 522 554 … … 1489 1521 1490 1522 1491 =head1 UTF-8 and tainted data 1492 1493 Current implementation does not preserve UTF-8 flag on scalars. 1494 Storing UTF-8 string and retrieving it back would return the same byte 1495 sequence, but UTF-8 flag will be forgotten. See L<utf8|utf8>. 1496 1497 Likewise, tainted flag is neither tested nor preserved, storing 1498 tainted data and retrieving it back would clear tainted flag. See 1499 L<perlsec|perlsec>. 1523 =head1 Tainted data 1524 1525 In current implementation tainted flag is neither tested nor 1526 preserved, storing tainted data and retrieving it back would clear 1527 tainted flag. See L<perlsec|perlsec>. 1500 1528 1501 1529 … … 1565 1593 Development of this module is sponsored by S<Monashev Co. Ltd.> 1566 1594 1595 Thanks to Peter J. Holzer for enlightening on UTF-8 support. 1596 1567 1597 1568 1598 =head1 WARRANTY -
t/Memd.pm
r9a7c3a re68fca 29 29 ketama_points => 150, 30 30 nowait => 1, 31 utf8 => ($^V >= 5.008001 ? 1 : 0), 31 32 ); 32 33
Note: See TracChangeset
for help on using the changeset viewer.
