3 Replies Latest reply on May 8, 2013 6:50 AM by schmyrczyk

    Caching in web application

    tausif.razi

      Hey,

      I think you guys are making a pretty good forum.

      Since , I am new to caching I need some help in understanding cache in general (What is caching ?? adv n disadv of caching).

      And how can I implement caching in my web application.

      Please let me know about the tutorials or any relevant documents you guys have.

       

      Thanks,

      Tausif

        • 1. Re: Caching in web application
          schmyrczyk

          Hello Mohammad,

          Do you already know which version of JBoss Cache or Infinispan are you going to use?

          If you are not sure: On which JBoss version is your web application running?

           

          Regards,

          Lukas

          • 2. Re: Caching in web application
            tausif.razi

            Hey Lukas,

            Hope u r doing great.

            I am new to caching itself forget about JBoss.

            So I need some important information and knowledge before I start implementing it in my project.

            We are planning to use CouchBase .But , still we are looking for a better option.May be JBoss cache we will use.

            But before that I need to understand about the caching as a whole.

             

            Regards,

            Tausif

            • 3. Re: Caching in web application
              schmyrczyk

              Hey,

              at first you should gather some information about the topic cache itself.

              There is a good explanation at wikipedia (https://en.wikipedia.org/wiki/Cache_(computing)).

               

              I am not familiar with CouchBase. But since it provides key-value based access it sounds like a mix of a cache and a database.

              Most java cache implementations are key-value-based. So you can access them like a map.

              Here is an example how to access an infispan cache instance (Source: https://docs.jboss.org/author/display/ISPN/Getting+Started+Guide#GettingStartedGuide-5minutetutorial):

               

              38.       // Add a entry

              39.       cache.put("key", "value");

              40.       // Validate the entry is now in the cache

              41.       assertEqual(1, cache.size());

              42.       assertTrue(cache.containsKey("key"));

              43.       // Remove the entry from the cache

              44.       Object v = cache.remove("key");

              45.       // Validate the entry is no longer in the cache

              46.       assertEqual("value", v);

               

              In the past I have also worked with EHCache and JBoss Cache. They are used in a similar way like Infinispan. I have also to mention that there is no "best" cache. You have to evaluate some cache implementations for you project because it depends on a lot of aspects like access speed, clustering capabilities, caching algorithms, etc.

               

              For further information you could look up the following websites:

              http://www.coderanch.com/how-to/java/CachingStrategies

              http://infinispan.blogspot.co.uk/2010/02/infinispan-as-local-cache.html

               

              But do not forget evaluate your desired cache in order to get the best results for your application.

               

              Regards,

              Lukas