{"id":396974,"date":"2023-09-07T07:06:01","date_gmt":"2023-09-07T07:06:01","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=396974"},"modified":"2023-09-12T04:11:54","modified_gmt":"2023-09-12T04:11:54","slug":"how-to-use-redis-for-caching-store-api-in-shopware","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/","title":{"rendered":"How to use Redis for caching store API in Shopware"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>Hello tech geeks, today we will learn how to add caching in your custom store-api routes in shopware. For that we will start by looking at how to add a custom store-api route then we will see how to add a caching layer to it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why need caching in API?<\/h2>\n\n\n\n<p>Caching in APIs improves response times and reduces server load by storing and reusing frequently requested data, enhancing overall system efficiency and user experience.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before you start caching, it&#8217;s essential to have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A running instance of Shopware 6<\/li>\n\n\n\n<li>Basic knowledge of RESTful API and HTTP methods<\/li>\n\n\n\n<li>Basics of Symfony framework like dependency injection, annotations, decorate services, etc<\/li>\n\n\n\n<li>Basic knowledge of services and controller registration in shopware.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: How to add store-api route?<\/h2>\n\n\n\n<p>Begin by adding an <strong>abstract class<\/strong> that your route will extend.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;plugin Root&gt;\/src\/Core\/Content\/Example\/SalesChannel\/AbstractExampleRoute.php\n\n&lt;?php declare(strict_types=1);\n\nnamespace Webkul\\BasicExample\\Core\\Content\\Example\\SalesChannel;\n\nuse Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Criteria;\nuse Shopware\\Core\\System\\SalesChannel\\SalesChannelContext;\n\nabstract class AbstractExampleRoute\n{\n    abstract public function getDecorated(): AbstractExampleRoute;\n\n    abstract public function load(Criteria $criteria, SalesChannelContext $context): ExampleRouteResponse;\n}<\/pre>\n\n\n\n<p>Add <strong>route class<\/strong> by extending this <strong>abstract class<\/strong> and write methods as shown below,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;plugin Root&gt;\/src\/Core\/Content\/Example\/SalesChannel\/ExampleRoute.php\n\n&lt;?php declare(strict_types=1);\n\nnamespace Webkul\\BasicExample\\Core\\Content\\Example\\SalesChannel;\n\nuse Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository;\nuse Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Criteria;\nuse Shopware\\Core\\Framework\\Plugin\\Exception\\DecorationPatternException;\nuse Shopware\\Core\\Framework\\Routing\\Annotation\\Entity;\nuse Shopware\\Core\\System\\SalesChannel\\SalesChannelContext;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n\n\/**\n * @Route(defaults={&quot;_routeScope&quot;={&quot;store-api&quot;}})\n *\/\nclass ExampleRoute extends AbstractExampleRoute\n{\n    protected EntityRepository $exampleRepository;\n\n    public function __construct(EntityRepository $exampleRepository)\n    {\n        $this-&gt;exampleRepository = $exampleRepository;\n    }\n\n    public function getDecorated(): AbstractExampleRoute\n    {\n        throw new DecorationPatternException(self::class);\n    }\n\n    \/**\n     * @Entity(&quot;blog_example&quot;)\n     * @Route(&quot;\/store-api\/example&quot;, name=&quot;store-api.example.search&quot;, methods={&quot;GET&quot;, &quot;POST&quot;})\n     *\/\n    public function load(Criteria $criteria, SalesChannelContext $context): ExampleRouteResponse\n    {\n       $results = $this-&gt;exampleRepository-&gt;search($criteria, $context-&gt;getContext());\n        return new ExampleRouteResponse($results );\n    }\n}<\/pre>\n\n\n\n<p>Don&#8217;t forget to register your route in your <strong>services.xml<\/strong> file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;services&gt;\n        &lt;service id=&quot;Webkul\\BasicExample\\Core\\Content\\Example\\SalesChannel\\ExampleRoute&quot; &gt;\n            &lt;argument type=&quot;service&quot; id=&quot;blog_example.repository&quot;\/&gt;\n        &lt;\/service&gt;\n&lt;\/services&gt;<\/pre>\n\n\n\n<p>Now we have successfully set up our store-api route let&#8217;s see how we can add caching to it. For that, we will use the <strong>decorated class<\/strong> and implement our caching to it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: How to add a caching layer in store-API route?<\/h2>\n\n\n\n<p>In Shopware, the caching is pre-configured for us; we simply need to utilize the appropriate classes.<\/p>\n\n\n\n<p>We will start by adding a new class name cachedExampleRoute. This class will <strong>decorate<\/strong> our ExampleRoute class we just created above.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php declare(strict_types=1);\n\nnamespace Webkul\\BasicExample\\Core\\Content\\Example\\SalesChannel;\n\nuse Psr\\Log\\LoggerInterface;\nuse Shopware\\Core\\Framework\\Adapter\\Cache\\CacheStateSubscriber;\nuse Shopware\\Core\\System\\SalesChannel\\SalesChannelContext;\nuse Shopware\\Core\\Framework\\Adapter\\Cache\\AbstractCacheTracer;\nuse Shopware\\Core\\Framework\\Adapter\\Cache\\CacheCompressor;\nuse Shopware\\Core\\Framework\\DataAbstractionLayer\\Cache\\EntityCacheKeyGenerator;\nuse Symfony\\Component\\Cache\\Adapter\\TagAwareAdapterInterface;\nuse Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Criteria;\nuse Shopware\\Core\\Framework\\DataAbstractionLayer\\FieldSerializer\\JsonFieldSerializer;\nuse Shopware\\Core\\Framework\\Routing\\Annotation\\Entity;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\nuse Webkul\\Core\\Content\\Blog\\SalesChannel\\BlogRouteResponse;\n\n\/**\n * @Route(defaults={&quot;_routeScope&quot;={&quot;store-api&quot;}})\n *\/\nclass CachedExampleRoute extends AbstractExampleRoute\n{\n    private AbstractExampleRoute $decorated;\n\n    private TagAwareAdapterInterface $cache;\n\n    private EntityCacheKeyGenerator $generator;\n\n    private AbstractCacheTracer $tracer;\n\n    private array $states;\n\n    private LoggerInterface $logger;\n\n    public function __construct(\n        AbstractExampleRoute $decorated,\n        TagAwareAdapterInterface $cache,\n        EntityCacheKeyGenerator $generator,\n        AbstractCacheTracer $tracer,\n        LoggerInterface $logger\n    ) {\n        $this-&gt;decorated = $decorated;\n        $this-&gt;cache = $cache;\n        $this-&gt;generator = $generator;\n        $this-&gt;tracer = $tracer;\n        \n        \/\/ declares that this route can not be cached if the customer is       logged in\n        $this-&gt;states = &#091;CacheStateSubscriber::STATE_LOGGED_IN];\n        $this-&gt;logger = $logger;\n    }\n    \n    public function getDecorated(): AbstractExampleRoute\n    {\n        return $this-&gt;decorated;\n    }\n\n    \/**\n     * @Entity(&quot;blog_example&quot;)\n     * @Route(&quot;\/store-api\/example&quot;, name=&quot;store-api.example.search&quot;, methods={&quot;GET&quot;, &quot;POST&quot;})\n     *\/\n    public function load(Criteria $criteria, SalesChannelContext $context): ExampleRouteResponse\n    {\n        \/\/ The context is provided with a state where the route cannot be  cached\n        if ($context-&gt;hasState(...$this-&gt;states)) {\n            return $this-&gt;getDecorated()-&gt;load($criteria, $context);\n        }\n\n        \/\/ Fetch item from the cache pool\n        $item = $this-&gt;cache-&gt;getItem(\n            $this-&gt;generateKey($context, $criteria)\n        );\n\n        try {\n            if ($item-&gt;isHit() &amp;&amp; $item-&gt;get()) {\n                \/\/ Use cache compressor to uncompress the cache value\n                return CacheCompressor::uncompress($item);\n            }\n        } catch (\\Throwable $e) {\n            \/\/ Something went wrong when uncompress the cache item - we log the error and continue to overwrite the invalid cache item \n            $this-&gt;logger-&gt;error($e-&gt;getMessage());\n        }\n\n        $name = self::buildName();\n        \/\/ start tracing of nested cache tags and system config keys\n        $response = $this-&gt;tracer-&gt;trace($name, function () use ($criteria, $context) {\n            return $this-&gt;getDecorated()-&gt;load($criteria, $context);\n        });\n        \n        \/\/ compress cache content to reduce cache size\n        $item = CacheCompressor::compress($item, $response);\n\n        $item-&gt;tag(array_merge(\n            \/\/ get traced tags and configs        \n            $this-&gt;tracer-&gt;get(self::buildName()),\n            &#091;self::buildName()]\n        ));\n\n        $this-&gt;cache-&gt;save($item);\n\n        return $response;\n    }\n    \n    public static function buildName(): string \n    {\n        return &#039;example-route&#039;;\n    }\n  \n    private function generateKey(SalesChannelContext $context, Criteria $criteria): string\n    {\n        $parts = &#091;\n            self::buildName(),\n            \/\/ generate a hash for the route criteria\n            $this-&gt;generator-&gt;getCriteriaHash($criteria),\n            \/\/ generate a hash for the current context \n            $this-&gt;generator-&gt;getSalesChannelContextHash($context),\n        ];\n          \n        return md5(JsonFieldSerializer::encodeJson($parts));\n    }\n}<\/pre>\n\n\n\n<p>Inject the class in <strong>services.xml<\/strong> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;service \n id=&quot;&lt;pluginRoot&gt;\\Core\\Content\\Example\\SalesChannel\\CachedExampleRoute&quot;  decorates=&quot;Webkul\\BasicExample\\Core\\Content\\Example\\SalesChannel\\ExampleRoute&quot;&gt;\n   &lt;argument type=&quot;service&quot; id=&quot; &lt;pluginRoot&gt;\\Core\\Content\\Example\\SalesChannel\\CachedExampleRoute.inner&quot;\/&gt;\n   &lt;argument type=&quot;service&quot; id=&quot;cache.object&quot;\/&gt;\n   &lt;argument type=&quot;service&quot; id=&quot;Shopware\\Core\\Framework\\DataAbstractionLayer\\Cache\\EntityCacheKeyGenerator&quot;\/&gt;\n   &lt;argument type=&quot;service&quot; id=&quot;Shopware\\Core\\Framework\\Adapter\\Cache\\CacheTracer&quot;\/&gt;\n   &lt;argument type=&quot;service&quot; id=&quot;logger&quot; \/&gt;\n&lt;\/service&gt;<\/pre>\n\n\n\n<p>As we can see below the response before the caching took more than 2 seconds,<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1200\" height=\"566\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/BeforeCache-1200x566.png\" alt=\"before caching store API\" class=\"wp-image-397227\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/BeforeCache-1200x566.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/BeforeCache-300x141.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/BeforeCache-250x118.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/BeforeCache-768x362.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/BeforeCache.png 1270w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><figcaption class=\"wp-element-caption\">Before caching store API<\/figcaption><\/figure>\n\n\n\n<p>And after caching the results are<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"568\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/AfterCache-1-1200x568.png\" alt=\"after caching store API\" class=\"wp-image-397319\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/AfterCache-1-1200x568.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/AfterCache-1-300x142.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/AfterCache-1-250x118.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/AfterCache-1-768x363.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/08\/AfterCache-1.png 1277w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><figcaption class=\"wp-element-caption\">After caching store API<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The caching in our API always results in <strong>better performance<\/strong> if implemented correctly. The cache can also result in <strong>outdated data<\/strong> and <strong>security risks<\/strong> if not set up properly. For a detailed guide on how to add cache in store API check out <a href=\"https:\/\/developer.shopware.com\/docs\/v\/6.4\/guides\/plugins\/plugins\/framework\/store-api\/add-caching-for-store-api-route\">shopware official documentation<\/a>. <\/p>\n\n\n\n<p>If you need custom&nbsp;<a href=\"https:\/\/webkul.com\/shopware-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">Shopware Development Services<\/a>&nbsp;then feel free to&nbsp;<a href=\"https:\/\/webkul.com\/contacts\" target=\"_blank\" rel=\"noreferrer noopener\">reach us<\/a>&nbsp;and also explore our exclusive range of&nbsp;<a href=\"https:\/\/store.webkul.com\/Shopware.html\">Shopware Plugins<\/a>.<\/p>\n\n\n\n<p>Have fun and keep coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Hello tech geeks, today we will learn how to add caching in your custom store-api routes in shopware. For that we will start by looking at how to add a custom store-api route then we will see how to add a caching layer to it. Why need caching in API? Caching in APIs improves <a href=\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":553,"featured_media":377636,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-396974","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use Redis for caching Store API in Shopware- Webkul Blog<\/title>\n<meta name=\"description\" content=\"Learn how to implement caching in store-API in shopware to boost your API performance. Start by adding store-API route then caching route.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use Redis for caching Store API in Shopware- Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Learn how to implement caching in store-API in shopware to boost your API performance. Start by adding store-API route then caching route.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-09-07T07:06:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-12T04:11:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/icons.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"675\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Sahil Jassal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sahil Jassal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/\"},\"author\":{\"name\":\"Sahil Jassal\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/5ea360163b2e7f5de2f54f0669c71cac\"},\"headline\":\"How to use Redis for caching store API in Shopware\",\"datePublished\":\"2023-09-07T07:06:01+00:00\",\"dateModified\":\"2023-09-12T04:11:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/\"},\"wordCount\":362,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/icons.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/\",\"name\":\"How to use Redis for caching Store API in Shopware- Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/icons.png\",\"datePublished\":\"2023-09-07T07:06:01+00:00\",\"dateModified\":\"2023-09-12T04:11:54+00:00\",\"description\":\"Learn how to implement caching in store-API in shopware to boost your API performance. Start by adding store-API route then caching route.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/icons.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/icons.png\",\"width\":1200,\"height\":675,\"caption\":\"icons\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use Redis for caching store API in Shopware\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/5ea360163b2e7f5de2f54f0669c71cac\",\"name\":\"Sahil Jassal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/45a97e1535b57511edfea77c52cfe561f372e6087f788cd886be7e1dd2fca943?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/45a97e1535b57511edfea77c52cfe561f372e6087f788cd886be7e1dd2fca943?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Sahil Jassal\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/sahil-jassal021\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use Redis for caching Store API in Shopware- Webkul Blog","description":"Learn how to implement caching in store-API in shopware to boost your API performance. Start by adding store-API route then caching route.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/","og_locale":"en_US","og_type":"article","og_title":"How to use Redis for caching Store API in Shopware- Webkul Blog","og_description":"Learn how to implement caching in store-API in shopware to boost your API performance. Start by adding store-API route then caching route.","og_url":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-09-07T07:06:01+00:00","article_modified_time":"2023-09-12T04:11:54+00:00","og_image":[{"width":1200,"height":675,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/icons.png","type":"image\/png"}],"author":"Sahil Jassal","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Sahil Jassal","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/"},"author":{"name":"Sahil Jassal","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/5ea360163b2e7f5de2f54f0669c71cac"},"headline":"How to use Redis for caching store API in Shopware","datePublished":"2023-09-07T07:06:01+00:00","dateModified":"2023-09-12T04:11:54+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/"},"wordCount":362,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/icons.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/","url":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/","name":"How to use Redis for caching Store API in Shopware- Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/icons.png","datePublished":"2023-09-07T07:06:01+00:00","dateModified":"2023-09-12T04:11:54+00:00","description":"Learn how to implement caching in store-API in shopware to boost your API performance. Start by adding store-API route then caching route.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/icons.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/icons.png","width":1200,"height":675,"caption":"icons"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-use-redis-for-caching-store-api-in-shopware\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to use Redis for caching store API in Shopware"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/5ea360163b2e7f5de2f54f0669c71cac","name":"Sahil Jassal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/45a97e1535b57511edfea77c52cfe561f372e6087f788cd886be7e1dd2fca943?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/45a97e1535b57511edfea77c52cfe561f372e6087f788cd886be7e1dd2fca943?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Sahil Jassal"},"url":"https:\/\/webkul.com\/blog\/author\/sahil-jassal021\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/396974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/553"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=396974"}],"version-history":[{"count":21,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/396974\/revisions"}],"predecessor-version":[{"id":399465,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/396974\/revisions\/399465"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/377636"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=396974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=396974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=396974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}