2 Replies Latest reply on Feb 12, 2010 7:14 AM by yahro

    ProtocolBuffers objects in the cache

    yahro

      Hi,

       

      I would like to store objects generated by Google's ProtocolBuffers in the cache. Do I need to write my own Externalizer for them? I noticed that Infinispan is using @Marshallable annotation for creating own externalizers. How can I do similar thing without using annotations?

       

      Best regards,

      Jarek

        • 1. Re: ProtocolBuffers objects in the cache
          manik
          The @Marshallable stuff is internal only (for now).  We may make it public API at some point, once we have a proper scheme to ensure magic numbers don't collide.

           

          Re: protobufs, the best way to do this is for you to handle the marshalling of values outside of the cache.  E.g., Object -> byte[], and then cache.put(key, byte[]).

           

          HTH,

          Manik

          • 2. Re: ProtocolBuffers objects in the cache
            yahro

            Thanks for info, for now I'll stick to using byte[]. In the future it would be nice to be able to use generics e.g.

             

            ConcurrentMap<Integer, SomeProtoBufClass> myTypeSafeCache = manager.getCache("myCache");

             

            In order to do this kind of stuff efficiently, flexible (extensible) serialization mechanism would be helpful.

             

            The simplest solution might be adding configuration parameter to the cache (serializer="mySerializerClass"). Serializer class would implement Infinispan interface, which would declare methods to do conversion Object <-> byte[]. That way everyone could plug whatever they come up with (for instance Protocol Buffer). Just a suggestion .

             

            Best regards,

            Jarek