Springboot Ehcache load data












0
















  • Service using SpringBoot, Maven, MongoDB, Ehcache.


  • Service requires a fast and frequently cache server, so eventually, I chose Ehcache.


  • All the cache will be called almost at the same frequency so there are no hot cold data in this case.


  • The original data in MongoDB will be updated every day by a timer service, so what I do is to load all the updated data to Ehcache every day.


  • Each item in this data has a connection with each other, like you use one to find the relevant Ids of the other. So if one cache is updated, but the other one hasn't, then you can't find these relevant Ids. I want to avoid this situation.



So my question is, is there any way to achieve a function like this, like using two Ehcache servers or something? i.e. When one is in use, the other one can load the data from MongoDB. When the update is done, switch it to the updated one. So every day when the MongoDB data updated, and I have to update the Ehcache data, it won't influence my current cache. That's just a thought I have. Another thought is something like a SQL transaction. Is there any other way to achieve this.



Please advise.










share|improve this question





























    0
















    • Service using SpringBoot, Maven, MongoDB, Ehcache.


    • Service requires a fast and frequently cache server, so eventually, I chose Ehcache.


    • All the cache will be called almost at the same frequency so there are no hot cold data in this case.


    • The original data in MongoDB will be updated every day by a timer service, so what I do is to load all the updated data to Ehcache every day.


    • Each item in this data has a connection with each other, like you use one to find the relevant Ids of the other. So if one cache is updated, but the other one hasn't, then you can't find these relevant Ids. I want to avoid this situation.



    So my question is, is there any way to achieve a function like this, like using two Ehcache servers or something? i.e. When one is in use, the other one can load the data from MongoDB. When the update is done, switch it to the updated one. So every day when the MongoDB data updated, and I have to update the Ehcache data, it won't influence my current cache. That's just a thought I have. Another thought is something like a SQL transaction. Is there any other way to achieve this.



    Please advise.










    share|improve this question



























      0












      0








      0









      • Service using SpringBoot, Maven, MongoDB, Ehcache.


      • Service requires a fast and frequently cache server, so eventually, I chose Ehcache.


      • All the cache will be called almost at the same frequency so there are no hot cold data in this case.


      • The original data in MongoDB will be updated every day by a timer service, so what I do is to load all the updated data to Ehcache every day.


      • Each item in this data has a connection with each other, like you use one to find the relevant Ids of the other. So if one cache is updated, but the other one hasn't, then you can't find these relevant Ids. I want to avoid this situation.



      So my question is, is there any way to achieve a function like this, like using two Ehcache servers or something? i.e. When one is in use, the other one can load the data from MongoDB. When the update is done, switch it to the updated one. So every day when the MongoDB data updated, and I have to update the Ehcache data, it won't influence my current cache. That's just a thought I have. Another thought is something like a SQL transaction. Is there any other way to achieve this.



      Please advise.










      share|improve this question

















      • Service using SpringBoot, Maven, MongoDB, Ehcache.


      • Service requires a fast and frequently cache server, so eventually, I chose Ehcache.


      • All the cache will be called almost at the same frequency so there are no hot cold data in this case.


      • The original data in MongoDB will be updated every day by a timer service, so what I do is to load all the updated data to Ehcache every day.


      • Each item in this data has a connection with each other, like you use one to find the relevant Ids of the other. So if one cache is updated, but the other one hasn't, then you can't find these relevant Ids. I want to avoid this situation.



      So my question is, is there any way to achieve a function like this, like using two Ehcache servers or something? i.e. When one is in use, the other one can load the data from MongoDB. When the update is done, switch it to the updated one. So every day when the MongoDB data updated, and I have to update the Ehcache data, it won't influence my current cache. That's just a thought I have. Another thought is something like a SQL transaction. Is there any other way to achieve this.



      Please advise.







      spring-boot ehcache






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 7:02









      Rohit416

      2,57031634




      2,57031634










      asked Nov 15 '18 at 6:34









      Summer XiaSummer Xia

      11




      11
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Good question. I see two ways.



          One is to use an application lock. When you are ready to reload the cache, you block access to it and do it. There is no way to clear all caches are the same time. The problem is that everything will be blocked during the update.



          The other way is to use an other cache. So you load the new cache with the new data and then swap the new cache and the expired one. The problem with this solution is that at a given moment you will take twice the memory since both caches are in memory.






          share|improve this answer
























          • Yes. I prefer the first solution cuz memory cost too much after all. Thank you!

            – Summer Xia
            Nov 26 '18 at 2:20











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313707%2fspringboot-ehcache-load-data%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Good question. I see two ways.



          One is to use an application lock. When you are ready to reload the cache, you block access to it and do it. There is no way to clear all caches are the same time. The problem is that everything will be blocked during the update.



          The other way is to use an other cache. So you load the new cache with the new data and then swap the new cache and the expired one. The problem with this solution is that at a given moment you will take twice the memory since both caches are in memory.






          share|improve this answer
























          • Yes. I prefer the first solution cuz memory cost too much after all. Thank you!

            – Summer Xia
            Nov 26 '18 at 2:20
















          0














          Good question. I see two ways.



          One is to use an application lock. When you are ready to reload the cache, you block access to it and do it. There is no way to clear all caches are the same time. The problem is that everything will be blocked during the update.



          The other way is to use an other cache. So you load the new cache with the new data and then swap the new cache and the expired one. The problem with this solution is that at a given moment you will take twice the memory since both caches are in memory.






          share|improve this answer
























          • Yes. I prefer the first solution cuz memory cost too much after all. Thank you!

            – Summer Xia
            Nov 26 '18 at 2:20














          0












          0








          0







          Good question. I see two ways.



          One is to use an application lock. When you are ready to reload the cache, you block access to it and do it. There is no way to clear all caches are the same time. The problem is that everything will be blocked during the update.



          The other way is to use an other cache. So you load the new cache with the new data and then swap the new cache and the expired one. The problem with this solution is that at a given moment you will take twice the memory since both caches are in memory.






          share|improve this answer













          Good question. I see two ways.



          One is to use an application lock. When you are ready to reload the cache, you block access to it and do it. There is no way to clear all caches are the same time. The problem is that everything will be blocked during the update.



          The other way is to use an other cache. So you load the new cache with the new data and then swap the new cache and the expired one. The problem with this solution is that at a given moment you will take twice the memory since both caches are in memory.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 1:08









          HenriHenri

          3,60911322




          3,60911322













          • Yes. I prefer the first solution cuz memory cost too much after all. Thank you!

            – Summer Xia
            Nov 26 '18 at 2:20



















          • Yes. I prefer the first solution cuz memory cost too much after all. Thank you!

            – Summer Xia
            Nov 26 '18 at 2:20

















          Yes. I prefer the first solution cuz memory cost too much after all. Thank you!

          – Summer Xia
          Nov 26 '18 at 2:20





          Yes. I prefer the first solution cuz memory cost too much after all. Thank you!

          – Summer Xia
          Nov 26 '18 at 2:20




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313707%2fspringboot-ehcache-load-data%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python