<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Dreamwidth Development Training</title>
  <link>https://dw-dev-training.dreamwidth.org/</link>
  <description>Dreamwidth Development Training - Dreamwidth Studios</description>
  <lastBuildDate>Sun, 23 Dec 2012 15:44:13 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>dw_dev_training</lj:journal>
  <lj:journaltype>community</lj:journaltype>
  <image>
    <url>https://v2.dreamwidth.org/92798/30813</url>
    <title>Dreamwidth Development Training</title>
    <link>https://dw-dev-training.dreamwidth.org/</link>
    <width>100</width>
    <height>100</height>
  </image>

<item>
  <guid isPermaLink='true'>https://dw-dev-training.dreamwidth.org/42012.html</guid>
  <pubDate>Sun, 23 Dec 2012 15:44:13 GMT</pubDate>
  <title>Using memcache</title>
  <link>https://dw-dev-training.dreamwidth.org/42012.html</link>
  <description>Posted by: &lt;span lj:user=&apos;swaldman&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://swaldman.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://swaldman.dreamwidth.org/&apos;&gt;&lt;b&gt;swaldman&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is the first time I&apos;ve tried using memcache, so I thought I&apos;d post here and check I&apos;m doing it right.&lt;br /&gt;This is perhaps a slightly unusual application, because it isn&apos;t for caching something that&apos;s in the db.&lt;br /&gt;&lt;br /&gt;Scenario: There is a Twitter config variable that we need to know, which changes occasionally. There&apos;s a Twitter API call to find it out, but they ask that people don&apos;t call this more than once a day. So, my intention is along these lines:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
#allow an override, and also a fallback for sites that don&apos;t use memcache.
return $LJ::MYVARIABLE if $LJ::MYVARIABLE

my $value = LJ::MemCache::get( &apos;mykey&apos; );
return $value if $value;

#we clearly don&apos;t have it at present
#Do stuff to get the value from Twitter.

LJ::MemCache::set( &apos;mykey&apos;, $value, 24*60*60 );
return $value;
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, does the above make sense? Am I doing things correctly? Is there a convention as to what the key should be called?&lt;br /&gt;&lt;br /&gt;Thanks :-)&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=dw_dev_training&amp;ditemid=42012&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://dw-dev-training.dreamwidth.org/42012.html</comments>
  <category>memcache</category>
  <lj:music>Panama Rag</lj:music>
  <lj:security>public</lj:security>
  <lj:poster>swaldman</lj:poster>
  <lj:reply-count>4</lj:reply-count>
</item>
</channel>
</rss>
