6 Replies Latest reply on Mar 11, 2011 5:44 AM by galder.zamarreno

    Create Cache at runtime?

    amalrajvinoth

      Dear All,

       

      is it possible to create cache at runtime? if so what is method name?

       

      i mean, when i try to create using cachemanager.getCache("test");

       

      if "test" is not available what is the output? if i want to create the cache ie "test" which is not available at runtime. How to create it?

       

       

      thanks.

        • 1. Create Cache at runtime?
          jombo

          when u are using the api "cachemanager.getCache(name)"  while the name is not exist in the namecache configration,  Infinispan will create a cache according with the default cache configration

          1 of 1 people found this helpful
          • 2. Create Cache at runtime?
            amalrajvinoth

            By mistake, if we provide wrong cache name in getCache("wrong name"), then it should produce exception right?

            • 3. Create Cache at runtime?
              jombo

              what does the "wrong name" mean?

              a exist namedcache that has been start or create? or a unexist namedcache?

              if mean a existed cache, it won' t throw a  exception but return the exist cache that has been created

              • 4. Create Cache at runtime?
                amalrajvinoth

                I mean, i want to create cache at runtime programatically?

                 

                is there any provision to do that?

                • 5. Create Cache at runtime?
                  brenuart

                  Checkout the online documentation, javadoc and put your hands in the dirt.

                  That's the best advice I could give you.

                   

                  And, calling CacheManager.getCache(name) will create a new cache with name "name" if it does not exist yet.

                  If the configuration you gave to the CacheManager when you first created it contains elements for this named-cache, they will be used. Otherwise, this new cache will inherit the default configuration.

                  1 of 1 people found this helpful
                  • 6. Create Cache at runtime?
                    galder.zamarreno

                    If you want such an strict behaivour, you can always call EmbeddedCacheManager.getCacheNames and see if the cache you wanna get is there or not and act accordingly. That's what the Infinispan servers do to make sure you only to talk to predefined caches.