<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>redis | Nerdpress.org</title>
	<atom:link href="https://nerdpress.org/tag/redis/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerdpress.org</link>
	<description>...dev, tech problems and solutions.</description>
	<lastBuildDate>Fri, 04 May 2018 12:55:09 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Symfony Cache Component with SncRedisBundle</title>
		<link>https://nerdpress.org/2016/08/23/symfony-cache-component-sncredisbundle/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Tue, 23 Aug 2016 07:45:46 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[redis]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2716</guid>

					<description><![CDATA[<p>Since version 3.1 there is a Cache component with a PSR-6 implementation integrated in Symfony. So we do not need to add a 3rd party lib as Doctrine Cache anymore when we need caching these days. Doctrine Cache does the job but by implementing a standard the Symfony Cache seems to have another advantage besides &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2016/08/23/symfony-cache-component-sncredisbundle/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony Cache Component with SncRedisBundle"</span></a></p>
The post <a href="https://nerdpress.org/2016/08/23/symfony-cache-component-sncredisbundle/">Symfony Cache Component with SncRedisBundle</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>Since version 3.1 there is a Cache component with a <a href="http://www.php-fig.org/psr/psr-6/" target="_blank">PSR-6</a> implementation integrated in <a href="https://symfony.com/" target="_blank">Symfony</a>.<br />
So we do not need to add a 3rd party lib as <a href="https://github.com/doctrine/cache" target="_blank">Doctrine Cache</a> anymore when we need caching these days.</p>
<p>Doctrine Cache does the job but by implementing a standard the Symfony Cache seems to have another advantage besides its delievered anyway. So i checked it out.</p>
<p>Documentation is still a bit sparse and the best resource so far is this blogpost:<br />
<a href="https://symfony.com/blog/new-in-symfony-3-1-cache-component" target="_blank">https://symfony.com/blog/new-in-symfony-3-1-cache-component</a></p>
<p>I wont go into detail on how you use the Cache but rather how you integrate it with Redis, which is my favourite Cache backend.<br />
<span id="more-2716"></span></p>
<p>You can create a Cache service via the FrameworkBundle in your config.yml and you can also create a default Redis client to use with your Cache service.</p>
<pre class="brush: plain; title: ; notranslate">
framework:
    default_locale: de
    secret: ThisTokenIsNotSoSecretChangeIt
    assets: ~
    templating:
        engines: &#x5B;'twig']
    cache:
	default_redis_provider: &quot;redis://%cache.redis_host%:%cache.redis_port%/%cache:redis_db%&quot;
        pools:
           sf_cache:
             adapter: cache.adapter.redis
             public: true
             default_lifetime: 1200
             provider: cache.default_redis_provider
</pre>
<p>When the Redis Extension is present it will use the extension elsewards it will use Predis, which is plain PHP.<br />
You can also pass any other client. F.e. if you have already created a Predis client service in your app then just pass this as provider.</p>
<pre class="brush: plain; title: ; notranslate">
    cache:
        pools:
           sf_cache:
             adapter: cache.adapter.redis
             public: true
             default_lifetime: 1200
             provider: my.predis.client.service.id
</pre>
<p>I recently discovered <a href="https://github.com/snc/SncRedisBundle" target="_blank">SncRedisBundle</a> and i have to say i like it :)<br />
I used to create Predis clients directly because its very easy and thought i wouldnt need a bundle for this.<br />
But with SncRedisBundle you get Logging and WebProfiler support additionally, which is great for development.<br />
Also you get some more easy symfony integrations for other stuff as Doctrine, Mailings or Sessions which i dont use but maybe you do.<br />
So check it out.</p>
<p>So my best move is to use <a href="https://github.com/snc/SncRedisBundle" target="_blank">SncRedisBundle</a> to create a Redis client and integrate it with the Cache Component.</p>
<pre class="brush: plain; title: ; notranslate">
snc_redis:
    clients:
        sf_cache:
            type: predis
            alias: sf_cache
            dsn: &quot;redis://%cache.redis_host%:%cache.redis_port%/0&quot;
            logging: &quot;%kernel.debug%&quot;

framework:
    default_locale: de
    secret: ThisTokenIsNotSoSecretChangeIt
    assets: ~
    templating:
        engines: &#x5B;'twig']
    cache:
        pools:
           sf_cache:
             adapter: cache.adapter.redis
             public: true
             default_lifetime: 1200
             provider: snc_redis.sf_cache
</pre>
<p><a href="https://nerdpress.org/wp-content/uploads/2016/08/Bildschirmfoto-vom-2016-08-23-09-37-43.png"><img decoding="async" src="https://nerdpress.org/wp-content/uploads/2016/08/Bildschirmfoto-vom-2016-08-23-09-37-43-300x64.png" alt="Bildschirmfoto vom 2016-08-23 09-37-43" width="300" height="64" class="alignnone size-medium wp-image-2721" srcset="https://nerdpress.org/wp-content/uploads/2016/08/Bildschirmfoto-vom-2016-08-23-09-37-43-300x64.png 300w, https://nerdpress.org/wp-content/uploads/2016/08/Bildschirmfoto-vom-2016-08-23-09-37-43.png 501w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Now you have integrated caching with webprofiler appearance and logging, nice!</p>
<p><strong>UPDATE </strong><br />
You can also add your snc redis client to the standard app cache, provided with symfony:</p>
<pre class="brush: plain; title: ; notranslate">
cache:
    prefix_seed: my-app
    app: cache.adapter.redis
    system: cache.adapter.redis
    default_redis_provider: snc_redis.cache
</pre>The post <a href="https://nerdpress.org/2016/08/23/symfony-cache-component-sncredisbundle/">Symfony Cache Component with SncRedisBundle</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>tell redis db to not persist</title>
		<link>https://nerdpress.org/2011/10/27/tell-redis-db-to-not-persist/</link>
					<comments>https://nerdpress.org/2011/10/27/tell-redis-db-to-not-persist/#comments</comments>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Thu, 27 Oct 2011 15:22:30 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[redis]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=1915</guid>

					<description><![CDATA[<p>redis persists its memory data in snapshot style in every n seconds depending on your configuration. read more here. perhaps you would like to use redis as a pure in-memory db, like f.e. memchache. you can tell redis to not persist and save some bits&#38;miliseconds. this could be the case when using redis as a &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2011/10/27/tell-redis-db-to-not-persist/" class="more-link">Continue reading<span class="screen-reader-text"> "tell redis db to not persist"</span></a></p>
The post <a href="https://nerdpress.org/2011/10/27/tell-redis-db-to-not-persist/">tell redis db to not persist</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p><a href="http://redis.io">redis</a> persists its memory data in snapshot style in every <em>n</em> seconds depending on your configuration.<br />
read more <a href="http://redis.io/topics/persistence">here</a>.<br />
perhaps you would like to use redis as a pure in-memory db, like f.e. memchache.<br />
you can tell redis to not persist and save some bits&amp;miliseconds.<br />
this could be the case when using redis as a f.e. realtime queue, you wont need persistence,<br />
because you could say: nobody needs is newsfeed from the that day before the machine crashed ;)</p>
<p>alright, do so by:<br />
<span id="more-1915"></span></p>
<p>open:<br />
/etc/redis/redis.conf</p>
<p>you will find:</p>
<pre class="brush: bash; title: ; notranslate">
#   Note: you can disable saving at all commenting all the &quot;save&quot; lines.

save 900 1
save 300 10
save 60 10000
</pre>
<p>do as you are told:</p>
<pre class="brush: bash; title: ; notranslate">
#save 900 1
#save 300 10
#save 60 10000
</pre>
<p>&#8230;and save.<br />
then restart redis.</p>
<pre class="brush: bash; title: ; notranslate">
sudo /etc/init.d/redis-server restart
</pre>
<p>Doing!</p>The post <a href="https://nerdpress.org/2011/10/27/tell-redis-db-to-not-persist/">tell redis db to not persist</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2011/10/27/tell-redis-db-to-not-persist/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
