2 Replies Latest reply: Dec 17, 2013 4:38 AM by user123799 RSS

    what is the max length of Key supported on Coherence cache

    SrikanthGutha

      Hello everyone,

       

      Could someone tell me what the max key length supported on Coherence? I am planning to build the key something like this parameter1,parameter2,parameter3...parameterN.

      E.g. Parameter 1 = 112350

             Parameter 2 = 2012

             Parameter 3 = 4

             Parameter 4 = 160

             Parameter 5 = 12

       

      My key would be "112350,2012,4,160,12".  Is there any limit on Key length?

       

      Thanks in advance!

       

      Srikanth

        • 1. Re: what is the max length of Key supported on Coherence cache
          SrikanthGutha

          Hi,

           

          Could someone help me with this question? If the max key length is not long enough I would have to think of a different approach.

           

          The reason why I am concatenating all parameters with comma delimiter is to avoid key collision and to make sure 100% 1 to 1 mapping between key and value.

           

          Thanks,

          Srikanth

          • 2. Re: what is the max length of Key supported on Coherence cache
            user123799

            Keys in Coherence are just objects - any object. So the limit to the size of a key is the amount of memory Coherence has available to it AFAIK.

             

            In practice, it obviously makes sense to keep your keys small - no one wants to pass a 1MB key around!  But there is no 'limit'.

             

            From your first post it looks like you're planning on encoding several parameters into a string, and you're wondering if there is a limit to the length - is this correct?  If so, then you're basically limited by the maximum length of a Java String i.e. ~2 billion chars.

             

            However, you might want to think about creating a type to hold your key rather than concatenating the data into a string.  I'm not aware of your use case, so can't say for certain, but if you ever foresee wanting to search based on only some of your parameters then having objects, rather than strings, may make things easier.

             

            In short, would Coherence have an issue with a String key of "112350,2012,4,160,12" - most emphatically no.