On Dec 18, 2007 3:15 PM, Trustin Lee <[EMAIL PROTECTED]> wrote: > On Dec 17, 2007 5:20 PM, Steve Johns <[EMAIL PROTECTED]> wrote: > <snip/> > > > > > Can you give more hints about what the CACHE is? > > > > > > In you encoder, you could maintain a Map whose key is some message key > > > and whose value is encoded ByteBuffer (or byte[]). It could probably > > > be a LRUMap implementation that is provided by 3rd party collections > > > API such as Apache Commons Collections. You could query the map if > > > there's already an encoded form of the message, and reuse the encoded > > > data if there's one in your encoder implementation. > > > > Thanks. Trustin. I totally understood. However, where I do the message - > > > > byte[] part? Is that supposed to be in the Encoder? But what suggested > > seems doing the encoding message -> byte[] part in IoHandlerAdapter or > > Busniess logic. > Actually this issue bothered me for quite a while, I am working on a financial quotation server which broadcasts the quot data to all the end users connected. It seemed there is no choice than encoding message->byte[] in my IoHandlerAdapter in my case. If I do encoding in this way, I don't even need a cache and just send the byte[] to all the sessions with a LOOP( bytebuffer.duplicat() of course). Thanks. Anyways.
> > > Yes, you are supposed to do that in the ProtocolEncoder. It doesn't > mean that you can't do that in the IoHandlerAdaptor or business logic, > but it's not recommended in most cases. That's why I suggested you to > use cache in the encoder. > > HTH, > Trustin > -- > what we call human nature is actually human habit > -- > http://gleamynode.net/ > -- > PGP Key ID: 0x0255ECA6 >
