title: Cache data in SQL CE database
body: <p><strong>Background</strong></p>
  
  <p>I have an SQL CE database, that is constantly updated (every second).  </p>
  
  <p>I have a (web) application that allows a user to look at the data in real-time. At some point a user can click "take a snapshot" button, and it will open the snapshot in a different window.  </p>
  
  <p>And then on that form, there is "print" and "download" buttons that will either generate a page for printing, or will stream the data as CSV file - but <strong>same data snapshot has to be used</strong>, i.e. I can't go to the DB to get latest data for that.  </p>
  
  <p><strong>Details</strong>  </p>
  
  <ul>
  <li>SQL CE dabatase is exposed through WCF web service.  </li>
  <li>Snapshot consists of up to 500 records, 10 columns each. Expiration time on the snapshot of 2 hours is sufficient.</li>
  <li>It is a low-traffic application, so I don't expect more than few (5) connections at the same time.</li>
  <li>Loosing snapshot is not a big deal, user can simply generate new one.</li>
  <li>database is accessed by self-hosted WCF web service using Linq-to-SQL.</li>
  <li>Web site is ASP.NET MVC hosted on UltiDev Cassini.</li>
  <li>database, and web site are most likely be on the same box, when deployed. The entire app is intranet bound.</li>
  </ul>
  
  <p><strong>Problem</strong>
  I need to cache the snapshot of the data at the moment user pressed "take a snapshot" button, so that I can use same data to generate print page, or generate a file for download.</p>
  
  <p><strong>Solution 1:</strong></p>
  
  <p>Each time there is a need to generate a snapshot, I will create a table in the database. Since there are no temp tables in SQL CE, I will need to clean it up myself.  </p>
  
  <p><strong>Solution 2:</strong></p>
  
  <p>Cache the snapshot in-memory on either DB server, or web server.</p>
  
  <p><strong>Question:</strong> </p>
  
  <p>Is there anything wrong with proposed solutions? Any different solution suggestions?</p>