<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer">424</assigned-user-id>
  <attachments-count type="integer">2</attachments-count>
  <closed type="boolean">true</closed>
  <created-at type="datetime">2008-08-11T16:49:29+01:00</created-at>
  <creator-id type="integer">5701</creator-id>
  <milestone-due-on type="datetime" nil="true"></milestone-due-on>
  <milestone-id type="integer">9903</milestone-id>
  <number type="integer">800</number>
  <permalink>filestore-can-only-store-strings</permalink>
  <priority type="integer">261</priority>
  <project-id type="integer">8994</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>resolved</state>
  <tag>activesupport patch</tag>
  <title>FileStore can only store strings</title>
  <updated-at type="datetime">2008-08-14T02:59:40+01:00</updated-at>
  <user-id type="integer">424</user-id>
  <user-name>Joshua Peek</user-name>
  <creator-name>Ryan Bates</creator-name>
  <assigned-user-name>Joshua Peek</assigned-user-name>
  <url>http://rails.lighthouseapp.com/projects/8994/tickets/800</url>
  <milestone-title>2.x</milestone-title>
  <original-body>It is currently only possible to store strings in FileStore. All other objects are just converted to a string (to_s) so it's not possible to read them back as an object. This behavior is inconsistent with MemCacheStore and MemoryStore.

@@@ ruby
cache = ActiveSupport::Cache.lookup_store(:file_store, 'tmp/cache')
cache.write('foo', {:a =&gt; 1})
cache.read('foo') # =&gt; &quot;a1&quot; (hash as string)
@@@

The attached patch solves this by using Marshal on read/write. Like MemCacheStore this is overridable with the :raw option. Raw is used in fragment caching so that behaves like it used to (since it only stores strings).</original-body>
  <latest-body>It is currently only possible to store strings in FileStore. All other objects are just converted to a string (to_s) so it's not possible to read them back as an object. This behavior is inconsistent with MemCacheStore and MemoryStore.

@@@ ruby
cache = ActiveSupport::Cache.lookup_store(:file_store, 'tmp/cache')
cache.write('foo', {:a =&gt; 1})
cache.read('foo') # =&gt; &quot;a1&quot; (hash as string)
@@@

The attached patch solves this by using Marshal on read/write. Like MemCacheStore this is overridable with the :raw option. Raw is used in fragment caching so that behaves like it used to (since it only stores strings).</latest-body>
  <original-body-html>&lt;div&gt;&lt;p&gt;It is currently only possible to store strings in FileStore. All other objects are just converted to a string (to_s) so it's not possible to read them back as an object. This behavior is inconsistent with MemCacheStore and MemoryStore.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
cache = ActiveSupport::Cache.lookup_store(:file_store, 'tmp/cache')
cache.write('foo', {:a =&amp;gt; 1})
cache.read('foo') # =&amp;gt; &amp;quot;a1&amp;quot; (hash as string)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The attached patch solves this by using Marshal on read/write. Like MemCacheStore this is overridable with the :raw option. Raw is used in fragment caching so that behaves like it used to (since it only stores strings).&lt;/p&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>It is currently only possible to store strings in FileStore. All other objects are just converted to a string (to_s) so it's not possible to read them back as an object. This behavior is inconsistent with MemCacheStore and MemoryStore.

@@@ ruby
cache = ActiveSupport::Cache.lookup_store(:file_store, 'tmp/cache')
cache.write('foo', {:a =&gt; 1})
cache.read('foo') # =&gt; &quot;a1&quot; (hash as string)
@@@

The attached patch solves this by using Marshal on read/write. Like MemCacheStore this is overridable with the :raw option. Raw is used in fragment caching so that behaves like it used to (since it only stores strings).</body>
      <body-html>&lt;div&gt;&lt;p&gt;It is currently only possible to store strings in FileStore. All other objects are just converted to a string (to_s) so it's not possible to read them back as an object. This behavior is inconsistent with MemCacheStore and MemoryStore.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
cache = ActiveSupport::Cache.lookup_store(:file_store, 'tmp/cache')
cache.write('foo', {:a =&amp;gt; 1})
cache.read('foo') # =&amp;gt; &amp;quot;a1&amp;quot; (hash as string)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The attached patch solves this by using Marshal on read/write. Like MemCacheStore this is overridable with the :raw option. Raw is used in fragment caching so that behaves like it used to (since it only stores strings).&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-08-11T16:49:30+01:00</created-at>
      <creator-id type="integer">5701</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">800</number>
      <permalink>filestore-can-only-store-strings</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activesupport bug patch</tag>
      <title>FileStore can only store strings</title>
      <updated-at type="datetime">2008-08-11T16:49:30+01:00</updated-at>
      <user-id type="integer">5701</user-id>
      <user-name>Ryan Bates</user-name>
      <creator-name>Ryan Bates</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/800</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Skip the the :raw option and always marshal for consistent behavior. That raw option was only there to pass to memcache-client, we don't need it at the moment. Otherwise I'm down with the idea.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Skip the the :raw option and always marshal for consistent behavior. That raw option was only there to pass to memcache-client, we don't need it at the moment. Otherwise I'm down with the idea.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-08-11T20:59:22+01:00</created-at>
      <creator-id type="integer">5701</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: activesupport bug patch
:state: new
:assigned_user: 
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">800</number>
      <permalink>filestore-can-only-store-strings</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>open</state>
      <tag>activesupport patch</tag>
      <title>FileStore can only store strings</title>
      <updated-at type="datetime">2008-08-11T20:59:22+01:00</updated-at>
      <user-id type="integer">424</user-id>
      <user-name>Joshua Peek</user-name>
      <creator-name>Ryan Bates</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/800</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>Here's a patch which doesn't have the :raw option.

I originally thought it was necessary to support old fragment caches when one upgrades, but looks like &quot;nil&quot; will be returned on read if Marshal can't read the cache. Fragment caching is smart enough to rebuild the cache file if that happens (from looking at the code, but I haven't fully tested it).</body>
      <body-html>&lt;div&gt;&lt;p&gt;Here's a patch which doesn't have the :raw option.&lt;/p&gt;

&lt;p&gt;I originally thought it was necessary to support old fragment caches when one upgrades, but looks like &quot;nil&quot; will be returned on read if Marshal can't read the cache. Fragment caching is smart enough to rebuild the cache file if that happens (from looking at the code, but I haven't fully tested it).&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-08-11T21:36:55+01:00</created-at>
      <creator-id type="integer">5701</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">800</number>
      <permalink>filestore-can-only-store-strings</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>open</state>
      <tag>activesupport patch</tag>
      <title>FileStore can only store strings</title>
      <updated-at type="datetime">2008-08-11T21:36:55+01:00</updated-at>
      <user-id type="integer">5701</user-id>
      <user-name>Ryan Bates</user-name>
      <creator-name>Ryan Bates</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/800</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>Is there an easy to way to still read/write strings without marshaling? Just concerned about the speed impact.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Is there an easy to way to still read/write strings without marshaling? Just concerned about the speed impact.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-08-13T01:53:36+01:00</created-at>
      <creator-id type="integer">5701</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">800</number>
      <permalink>filestore-can-only-store-strings</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>open</state>
      <tag>activesupport patch</tag>
      <title>FileStore can only store strings</title>
      <updated-at type="datetime">2008-08-13T01:53:36+01:00</updated-at>
      <user-id type="integer">424</user-id>
      <user-name>Joshua Peek</user-name>
      <creator-name>Ryan Bates</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/800</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>It's easy enough to detect if the object is a string on write, but I don't know of a way to tell a normal string vs. a marshalled string on read. This is one reason we may want to keep the :raw option around? That way the developers can optimize their caching with :raw if they are just working with strings. And we can use that in the fragment cache to give a little speed boost since that is always strings.</body>
      <body-html>&lt;div&gt;&lt;p&gt;It's easy enough to detect if the object is a string on write, but I don't know of a way to tell a normal string vs. a marshalled string on read. This is one reason we may want to keep the :raw option around? That way the developers can optimize their caching with :raw if they are just working with strings. And we can use that in the fragment cache to give a little speed boost since that is always strings.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-08-13T17:49:07+01:00</created-at>
      <creator-id type="integer">5701</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">800</number>
      <permalink>filestore-can-only-store-strings</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>open</state>
      <tag>activesupport patch</tag>
      <title>FileStore can only store strings</title>
      <updated-at type="datetime">2008-08-13T17:49:07+01:00</updated-at>
      <user-id type="integer">5701</user-id>
      <user-name>Ryan Bates</user-name>
      <creator-name>Ryan Bates</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/800</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>Marshal load can take a file object and parse it as it reads the file. It is much faster than reading the whole file into a buffer and than unmarshaling it. After that change, I ran some benchmarks and there is barely any difference between marshaling. Its on all the time.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Marshal load can take a file object and parse it as it reads the file. It is much faster than reading the whole file into a buffer and than unmarshaling it. After that change, I ran some benchmarks and there is barely any difference between marshaling. Its on all the time.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-08-14T02:59:40+01:00</created-at>
      <creator-id type="integer">5701</creator-id>
      <diffable-attributes type="yaml">--- 
:state: open
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">800</number>
      <permalink>filestore-can-only-store-strings</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>activesupport patch</tag>
      <title>FileStore can only store strings</title>
      <updated-at type="datetime">2008-08-14T02:59:40+01:00</updated-at>
      <user-id type="integer">424</user-id>
      <user-name>Joshua Peek</user-name>
      <creator-name>Ryan Bates</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/800</url>
      <milestone-title>2.x</milestone-title>
    </version>
  </versions>
  <attachments type="array">
    <attachment type="Attachment">
      <code>942f32f04b0b1f3bb67ada32d51a832cdff026c9</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2008-08-11T16:49:30+01:00</created-at>
      <filename>marshal_in_file_store.diff</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">38404</id>
      <size type="integer">10830</size>
      <uploader-id type="integer">5701</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/38404/marshal_in_file_store.diff</url>
    </attachment>
    <attachment type="Attachment">
      <code>ff2d962429641742f77b711fff362534134482bb</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2008-08-11T21:36:55+01:00</created-at>
      <filename>marshal_in_file_store_no_raw.diff</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">38475</id>
      <size type="integer">2717</size>
      <uploader-id type="integer">5701</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/38475/marshal_in_file_store_no_raw.diff</url>
    </attachment>
  </attachments>
</ticket>
