{"id":858,"date":"2020-04-04T00:40:41","date_gmt":"2020-04-03T21:40:41","guid":{"rendered":""},"modified":"2020-09-09T21:06:12","modified_gmt":"2020-09-09T18:06:12","slug":"enable-redis-cache-compression","status":"publish","type":"docs","link":"https:\/\/microimpuls.com\/en\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression","title":{"rendered":"Enabling data compression in the cache"},"content":{"rendered":"<p>When using Smarty in cluster mode on multiple servers and with a heavy load from subscribers, you may face the need to reduce the amount of stored data in Redis and reduce the load on the network when transferring data between Redis and Smarty servers.<\/p>\n\n\n\n<p>Smarty allows you to compress data when stored in cache. This can cut data size and traffic in half.<\/p>\n\n\n\n<p>To enable compression, you must add to the section <code>CACHES<\/code> <code>OPTIONS<\/code> parameter <code>COMPRESSOR<\/code>for example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">CACHES = {\n\"default\":\n\"Backend\": \"core.cache.backends.RedisCache,\"\n\u201cLOCATION\u201d: \u201credis:\/\/ 10.0.0.1:7000\/0\",\"\n\"OPTIONS\":\n\"COMPRESSOR\": \"django_redis.compressors.zlib.ZlibCompressor,\"\n\"REDIS_CLIENT_CLASS\": \"rediscluster.client.RedisCluster,\"\n\"REDIS_CLIENT_KWARGS\": {\"read_from_replicas: True },\n\"CONNECTION_POOL_CLASS\": \"core.cache.cluster_connection.ClusterConnectionPool,\"\n\"CONNECTION_POOL_KWARGS\": {\n\"startup_nodes\":\n{\"host\": \"10.0.0.1\", \"port\": \"7000\", \"server_type: \"master\"},\n{\"host\": \"10.0.0.1\", \"port\": \"7000\", \"server_type: \"slave\"},\n{\"host\": \"10.0.0.1\", \"port\": \"7000\", \"server_type\": \"slave\"}\n]\n}\n}\n}\n}<\/pre>\n\n\n\n<p>Using data compression can slightly increase the load on the CPU.<\/p>","protected":false},"featured_media":0,"parent":857,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_links_to":"","_links_to_target":""},"doc_tag":[],"class_list":["post-858","docs","type-docs","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0435\u0448\u0435<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/microimpuls.com\/en\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0435\u0448\u0435\" \/>\n<meta property=\"og:description\" content=\"\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Smarty \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 \u0438 \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u0442 \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043c\u0430 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Redis \u0438 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0441\u0435\u0442\u044c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 Redis \u0438 Smarty. Smarty \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0432 \u043a\u0435\u0448. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0442\u0440\u0430\u0444\u0438\u043a \u0432\u0434\u0432\u043e\u0435. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/microimpuls.com\/en\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression\/\" \/>\n<meta property=\"og:site_name\" content=\"Microimpuls\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-09T18:06:12+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression\",\"url\":\"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression\",\"name\":\"\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0435\u0448\u0435\",\"isPartOf\":{\"@id\":\"https:\/\/micro.im\/#website\"},\"datePublished\":\"2020-04-03T21:40:41+00:00\",\"dateModified\":\"2020-09-09T18:06:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\",\"item\":\"https:\/\/micro.im\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Smarty\",\"item\":\"https:\/\/microimpuls.com\/docs\/smarty\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c\",\"item\":\"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0435\u0448\u0435\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/micro.im\/#website\",\"url\":\"https:\/\/micro.im\/\",\"name\":\"Microimpuls\",\"description\":\"\u041a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f OTT \u0438 IPTV\",\"publisher\":{\"@id\":\"https:\/\/micro.im\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/micro.im\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/micro.im\/#organization\",\"name\":\"Microimpuls\",\"url\":\"https:\/\/micro.im\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/micro.im\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/microimpuls.com\/wp-content\/uploads\/2024\/12\/mi-logo-square-en-black.png\",\"contentUrl\":\"https:\/\/microimpuls.com\/wp-content\/uploads\/2024\/12\/mi-logo-square-en-black.png\",\"width\":208,\"height\":219,\"caption\":\"Microimpuls\"},\"image\":{\"@id\":\"https:\/\/micro.im\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Enabling data compression in the cache","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:\/\/microimpuls.com\/en\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression\/","og_locale":"en_US","og_type":"article","og_title":"\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0435\u0448\u0435","og_description":"\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Smarty \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 \u0438 \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u0442 \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043c\u0430 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Redis \u0438 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0441\u0435\u0442\u044c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 Redis \u0438 Smarty. Smarty \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0432 \u043a\u0435\u0448. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0442\u0440\u0430\u0444\u0438\u043a \u0432\u0434\u0432\u043e\u0435. [&hellip;]","og_url":"https:\/\/microimpuls.com\/en\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression\/","og_site_name":"Microimpuls","article_modified_time":"2020-09-09T18:06:12+00:00","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression","url":"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression","name":"Enabling data compression in the cache","isPartOf":{"@id":"https:\/\/micro.im\/#website"},"datePublished":"2020-04-03T21:40:41+00:00","dateModified":"2020-09-09T18:06:12+00:00","breadcrumb":{"@id":"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy\/enable-redis-cache-compression#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430","item":"https:\/\/micro.im\/"},{"@type":"ListItem","position":2,"name":"Smarty","item":"https:\/\/microimpuls.com\/docs\/smarty"},{"@type":"ListItem","position":3,"name":"\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c","item":"https:\/\/microimpuls.com\/docs\/smarty\/scaling-and-redundancy"},{"@type":"ListItem","position":4,"name":"\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0435\u0448\u0435"}]},{"@type":"WebSite","@id":"https:\/\/micro.im\/#website","url":"https:\/\/micro.im\/","name":"Microimpulses","description":"Comprehensive solutions for OTT and IPTV","publisher":{"@id":"https:\/\/micro.im\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/micro.im\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/micro.im\/#organization","name":"Microimpulses","url":"https:\/\/micro.im\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/micro.im\/#\/schema\/logo\/image\/","url":"https:\/\/microimpuls.com\/wp-content\/uploads\/2024\/12\/mi-logo-square-en-black.png","contentUrl":"https:\/\/microimpuls.com\/wp-content\/uploads\/2024\/12\/mi-logo-square-en-black.png","width":208,"height":219,"caption":"Microimpuls"},"image":{"@id":"https:\/\/micro.im\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/docs\/858","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/comments?post=858"}],"version-history":[{"count":9,"href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/docs\/858\/revisions"}],"predecessor-version":[{"id":1216,"href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/docs\/858\/revisions\/1216"}],"up":[{"embeddable":true,"href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/docs\/857"}],"next":[{"title":"Configure Smarty Connection to SQL Cluster","link":"https:\/\/microimpuls.com\/en\/docs\/smarty\/scaling-and-redundancy\/smarty-sql-cluster-connection","href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/docs\/1312"}],"prev":[{"title":"Configure Redis Cluster and Connections in Smarty","link":"https:\/\/microimpuls.com\/en\/docs\/smarty\/scaling-and-redundancy\/redis-cluster-setup","href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/docs\/866"}],"wp:attachment":[{"href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/media?parent=858"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/microimpuls.com\/en\/wp-json\/wp\/v2\/doc_tag?post=858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}