Hi,

I would like to use a different Serializer with CHI in Mason.

Right now I use this setup:

    data_cache_api           => 'chi',
    data_cache_defaults      => {driver => 'Memcached', servers =>
'server.ip', namespace => 'project'}

I would like to use a different serializer than the default one
(Storable) because of problems with 32bit and 64bit system. I have a
mixed setup with older 32bit machines an newer ones, running on
64bit.Storable throws this error "Byte order is not compatible at ..."
and I tried to set $Storable::interwork_56_64bit to true (like
recommended in the manuals) but without any success.

So I would like to use a different serializer like JSON::XS.

I tired this:
    data_cache_defaults      => {driver => 'Memcached', servers =>
'server.ip', namespace => 'project', serializer => 'JSON'}

but I get this error: "Data::Serializer could not be loaded, cannot
handle serializer argument at
/usr/lib/perl5/Moose/Meta/TypeCoercion.pm line 63"

My solution right now is to overwrite the package, but there should be
a better way.

package CHI::Serializer::Storable;
use Moose;
use JSON::XS;
use strict;
use warnings;

__PACKAGE__->meta->make_immutable;

sub serialize {
  return encode_json( $_[1] );
}

sub deserialize {
  return decode_json( $_[1] );
}

sub serializer {
    return 'JSON';
}


-- 
citybeat.de: Bremens größtes Stadtmagazin im Internet.

Statistik Januar 2010:
Absolut eindeutige Besucher: 89.300
Pageviews: 1.662.344
Visits: 286.145
(alle Zahlen Google Analytics)

citybeat.de
Zum Huchtinger Bahnhof 13
28259 Bremen
Tel:  0421 - 16 80 80 - 0
Fax: 0421 - 16 80 80 - 80

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to