Does ServiceStack Cache Internal Requests?












1















If I use the .ToOptimizedResult (documented here) from a "bare" request like so:



var svc = new MyService();
var svcResul = svc.Any(new requestDTO() {..});


Will the performance of svcResult benefit from caching, or must it be called from Http/Messaging/Client ?



Note: app is actually running a servicestack container.. but caller above is not invoked from inside a service.










share|improve this question



























    1















    If I use the .ToOptimizedResult (documented here) from a "bare" request like so:



    var svc = new MyService();
    var svcResul = svc.Any(new requestDTO() {..});


    Will the performance of svcResult benefit from caching, or must it be called from Http/Messaging/Client ?



    Note: app is actually running a servicestack container.. but caller above is not invoked from inside a service.










    share|improve this question

























      1












      1








      1








      If I use the .ToOptimizedResult (documented here) from a "bare" request like so:



      var svc = new MyService();
      var svcResul = svc.Any(new requestDTO() {..});


      Will the performance of svcResult benefit from caching, or must it be called from Http/Messaging/Client ?



      Note: app is actually running a servicestack container.. but caller above is not invoked from inside a service.










      share|improve this question














      If I use the .ToOptimizedResult (documented here) from a "bare" request like so:



      var svc = new MyService();
      var svcResul = svc.Any(new requestDTO() {..});


      Will the performance of svcResult benefit from caching, or must it be called from Http/Messaging/Client ?



      Note: app is actually running a servicestack container.. but caller above is not invoked from inside a service.







      caching servicestack






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 11:35









      kevinckevinc

      367211




      367211
























          1 Answer
          1






          active

          oldest

          votes


















          1














          ServiceStack doesn't do any Request Caching by default, you have to opt-in to Caching using one of the caching strategies.



          You shouldn't use ToOptimizedResult() in Services that you wish to call directly, for cached Requests it returns a serialized compressed byte result which isn't accessible as a Typed Response DTO from C# API.



          For caching Services that you want to call via C# you can use the CacheResponse Attribute instead.



          Calling Other Services



          Note: The recommended way to call other Services is to use the Service Gateway, e.g:



          var result = Gateway.Send(new RequestDto());


          If you want to call the C# method on the Service directly you should use ResolveService to resolve an autowired Service and call the method within a using statement, e.g:



          using (var service = base.ResolveService<MyService>())
          {
          var result = service.Any(new RequestDto());
          }





          share|improve this answer


























          • thanks so much. One additional question, here docs.servicestack.net/cacheresponse-attribute it says the non-base url is the cache key - does this apply non non-http callers (does it serialize the request dto for the key, effectively?)

            – kevinc
            Nov 16 '18 at 21:26













          • @kevinc Caching and compression is only added for HTTP requests, I.e. for MQ or internal Service requests it’s executed without caching.

            – mythz
            Nov 20 '18 at 7:00











          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%2f53337073%2fdoes-servicestack-cache-internal-requests%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









          1














          ServiceStack doesn't do any Request Caching by default, you have to opt-in to Caching using one of the caching strategies.



          You shouldn't use ToOptimizedResult() in Services that you wish to call directly, for cached Requests it returns a serialized compressed byte result which isn't accessible as a Typed Response DTO from C# API.



          For caching Services that you want to call via C# you can use the CacheResponse Attribute instead.



          Calling Other Services



          Note: The recommended way to call other Services is to use the Service Gateway, e.g:



          var result = Gateway.Send(new RequestDto());


          If you want to call the C# method on the Service directly you should use ResolveService to resolve an autowired Service and call the method within a using statement, e.g:



          using (var service = base.ResolveService<MyService>())
          {
          var result = service.Any(new RequestDto());
          }





          share|improve this answer


























          • thanks so much. One additional question, here docs.servicestack.net/cacheresponse-attribute it says the non-base url is the cache key - does this apply non non-http callers (does it serialize the request dto for the key, effectively?)

            – kevinc
            Nov 16 '18 at 21:26













          • @kevinc Caching and compression is only added for HTTP requests, I.e. for MQ or internal Service requests it’s executed without caching.

            – mythz
            Nov 20 '18 at 7:00
















          1














          ServiceStack doesn't do any Request Caching by default, you have to opt-in to Caching using one of the caching strategies.



          You shouldn't use ToOptimizedResult() in Services that you wish to call directly, for cached Requests it returns a serialized compressed byte result which isn't accessible as a Typed Response DTO from C# API.



          For caching Services that you want to call via C# you can use the CacheResponse Attribute instead.



          Calling Other Services



          Note: The recommended way to call other Services is to use the Service Gateway, e.g:



          var result = Gateway.Send(new RequestDto());


          If you want to call the C# method on the Service directly you should use ResolveService to resolve an autowired Service and call the method within a using statement, e.g:



          using (var service = base.ResolveService<MyService>())
          {
          var result = service.Any(new RequestDto());
          }





          share|improve this answer


























          • thanks so much. One additional question, here docs.servicestack.net/cacheresponse-attribute it says the non-base url is the cache key - does this apply non non-http callers (does it serialize the request dto for the key, effectively?)

            – kevinc
            Nov 16 '18 at 21:26













          • @kevinc Caching and compression is only added for HTTP requests, I.e. for MQ or internal Service requests it’s executed without caching.

            – mythz
            Nov 20 '18 at 7:00














          1












          1








          1







          ServiceStack doesn't do any Request Caching by default, you have to opt-in to Caching using one of the caching strategies.



          You shouldn't use ToOptimizedResult() in Services that you wish to call directly, for cached Requests it returns a serialized compressed byte result which isn't accessible as a Typed Response DTO from C# API.



          For caching Services that you want to call via C# you can use the CacheResponse Attribute instead.



          Calling Other Services



          Note: The recommended way to call other Services is to use the Service Gateway, e.g:



          var result = Gateway.Send(new RequestDto());


          If you want to call the C# method on the Service directly you should use ResolveService to resolve an autowired Service and call the method within a using statement, e.g:



          using (var service = base.ResolveService<MyService>())
          {
          var result = service.Any(new RequestDto());
          }





          share|improve this answer















          ServiceStack doesn't do any Request Caching by default, you have to opt-in to Caching using one of the caching strategies.



          You shouldn't use ToOptimizedResult() in Services that you wish to call directly, for cached Requests it returns a serialized compressed byte result which isn't accessible as a Typed Response DTO from C# API.



          For caching Services that you want to call via C# you can use the CacheResponse Attribute instead.



          Calling Other Services



          Note: The recommended way to call other Services is to use the Service Gateway, e.g:



          var result = Gateway.Send(new RequestDto());


          If you want to call the C# method on the Service directly you should use ResolveService to resolve an autowired Service and call the method within a using statement, e.g:



          using (var service = base.ResolveService<MyService>())
          {
          var result = service.Any(new RequestDto());
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 16 '18 at 12:58

























          answered Nov 16 '18 at 12:23









          mythzmythz

          118k14196334




          118k14196334













          • thanks so much. One additional question, here docs.servicestack.net/cacheresponse-attribute it says the non-base url is the cache key - does this apply non non-http callers (does it serialize the request dto for the key, effectively?)

            – kevinc
            Nov 16 '18 at 21:26













          • @kevinc Caching and compression is only added for HTTP requests, I.e. for MQ or internal Service requests it’s executed without caching.

            – mythz
            Nov 20 '18 at 7:00



















          • thanks so much. One additional question, here docs.servicestack.net/cacheresponse-attribute it says the non-base url is the cache key - does this apply non non-http callers (does it serialize the request dto for the key, effectively?)

            – kevinc
            Nov 16 '18 at 21:26













          • @kevinc Caching and compression is only added for HTTP requests, I.e. for MQ or internal Service requests it’s executed without caching.

            – mythz
            Nov 20 '18 at 7:00

















          thanks so much. One additional question, here docs.servicestack.net/cacheresponse-attribute it says the non-base url is the cache key - does this apply non non-http callers (does it serialize the request dto for the key, effectively?)

          – kevinc
          Nov 16 '18 at 21:26







          thanks so much. One additional question, here docs.servicestack.net/cacheresponse-attribute it says the non-base url is the cache key - does this apply non non-http callers (does it serialize the request dto for the key, effectively?)

          – kevinc
          Nov 16 '18 at 21:26















          @kevinc Caching and compression is only added for HTTP requests, I.e. for MQ or internal Service requests it’s executed without caching.

          – mythz
          Nov 20 '18 at 7:00





          @kevinc Caching and compression is only added for HTTP requests, I.e. for MQ or internal Service requests it’s executed without caching.

          – mythz
          Nov 20 '18 at 7:00


















          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%2f53337073%2fdoes-servicestack-cache-internal-requests%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







          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini