… | |
… | |
57 | use JSON::XS 2.01 (); |
57 | use JSON::XS 2.01 (); |
58 | use BDB (); |
58 | use BDB (); |
59 | use Data::Dumper; |
59 | use Data::Dumper; |
60 | use Fcntl; |
60 | use Fcntl; |
61 | use YAML::XS (); |
61 | use YAML::XS (); |
|
|
62 | use CBOR::XS (); |
62 | use IO::AIO (); |
63 | use IO::AIO (); |
63 | use Compress::LZF; |
64 | use Compress::LZF; |
64 | use Digest::MD5 (); |
65 | use Digest::MD5 (); |
65 | |
66 | |
66 | AnyEvent::detect; |
67 | AnyEvent::detect; |
… | |
… | |
462 | |
463 | |
463 | =cut |
464 | =cut |
464 | |
465 | |
465 | sub decode_yaml($) { |
466 | sub decode_yaml($) { |
466 | fork_call { YAML::XS::Load $_[0] } @_ |
467 | fork_call { YAML::XS::Load $_[0] } @_ |
|
|
468 | } |
|
|
469 | |
|
|
470 | =item $scalar = cf::decode_cbor $scalar |
|
|
471 | |
|
|
472 | Same as CBOR::XS::decode_cbor, but takes server ticks into account, so |
|
|
473 | blocks. For small amounts of data, C<CBOR::XS::decode_cbor> is the better |
|
|
474 | alternative. |
|
|
475 | |
|
|
476 | =cut |
|
|
477 | |
|
|
478 | sub decode_cbor($) { |
|
|
479 | # we assume 10mb/s minimum decoding speed (on a ~2ghz machine) |
|
|
480 | cf::get_slot +(length $_[0]) / 10_000_000, 0, "decode_cbor"; |
|
|
481 | CBOR::XS::decode_cbor $_[0] |
467 | } |
482 | } |
468 | |
483 | |
469 | =item $scalar = cf::unlzf $scalar |
484 | =item $scalar = cf::unlzf $scalar |
470 | |
485 | |
471 | Same as Compress::LZF::compress, but takes server ticks into account, so |
486 | Same as Compress::LZF::compress, but takes server ticks into account, so |