<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : Record caching?</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Report Control : Record caching?]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Sun, 19 Apr 2026 04:15:22 +0000</pubDate>
  <lastBuildDate>Tue, 25 Jan 2011 11:45:07 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=17570</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[Record caching? : I ended up with another solution...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=62306&amp;title=record-caching#62306</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2657">Algae</a><br /><strong>Subject:</strong> 17570<br /><strong>Posted:</strong> 25 January 2011 at 11:45am<br /><br />I ended up with another solution which is pretty fast.<br><br>I load the data into CXTPReportRecords collection, then when I need to set it aside, I put that collection into a CMap. From the CMap I can then do a lookup when I need it again. The map is keyed to the database table name.<br><br>I suppose you could use an STL map if you prefer.<br><br>// set record collection to control.. add this method to cxtpreportcontrol.h (public!)<br>void SetRecords(CXTPReportRecords* pRecords)&nbsp; { m_pRecords = pRecords; }<br><br>// View class stuff<br><br>// record collection map in .h file<br>CMap&lt;CString,LPCTSTR,CXTPReportRecords*,CXTPReportRecords*&gt; recordMap;<br><br>// accessor for record collection<br>// if it returns false, use your loader to get the data straight from the database.<br>BOOL GetMappedRecords(CString db) <br>{ <br>&nbsp;&nbsp;&nbsp;&nbsp; CXTPReportRecords* pRecords;<br><br>&nbsp;&nbsp;&nbsp;&nbsp; if (recordMap.Lookup(db,pRecords))<br>&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; GetReportCtrl().SetRecords(pRecords);<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return TRUE;<br>&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp; &nbsp;&nbsp;&nbsp; return FALSE;<br>}<br><br>// in your view code somewhere<br>// Set data to map for subsequent retrieval.<br>// this is only necessary the first time a new table is encountered and you need to save // off the existing records.<br><br>CXTPReportRecords* pRecords = new CXTPReportRecords();<br>pRecords = GetReportCtrl().GetRecords();<br>// save old table data to the map for later lookup<br>recordMap.SetAt(oldDB, pRecords);<br>// get existing "new" records<br>if (!GetMappedRecords(newDB))<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp; .. if not in the map, use your loader to get records here<br>}<br>... make sure to populate (slow!)<br><br>// tear down when done, typically the view destructor<br>POSITION pos = recordMap.GetStartPosition();<br>while( pos != NULL )<br>{<br>&nbsp; &nbsp;&nbsp;&nbsp; CXTPReportRecords* pRecords;<br>&nbsp; &nbsp;&nbsp;&nbsp; CString str;<br><br>&nbsp; &nbsp;&nbsp;&nbsp; recordMap.GetNextAssoc( pos, str, pRecords );<br><br>// report control will cleanup the current data collection on it's own so we skip that one<br>&nbsp; &nbsp;&nbsp;&nbsp; if (GetReportCtrl().GetRecords() != pRecords)<br>&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pRecords-&gt;RemoveAll();<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; delete pRecords;<br>&nbsp; &nbsp;&nbsp;&nbsp; }<br>}<br>recordMap.RemoveAll();<br><br>*Note: In a multi-user environment you have to track record changes and update the records as usual.<br><br>*This gives up memory for speed.<br><br>]]>
   </description>
   <pubDate>Tue, 25 Jan 2011 11:45:07 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=62306&amp;title=record-caching#62306</guid>
  </item> 
  <item>
   <title><![CDATA[Record caching? : Back to square 1 with caching....]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61979&amp;title=record-caching#61979</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2657">Algae</a><br /><strong>Subject:</strong> 17570<br /><strong>Posted:</strong> 23 December 2010 at 12:20pm<br /><br />Back to square 1 with caching. <br><br>The property exchange code is too slow to be effective for large record sets. Performance degraded significantly with large sets.<br><br>Don't bother with this method. <img src="http://forum.codejock.com/smileys/smiley19.gif" border="0" alt="Cry" title="Cry" /><br>]]>
   </description>
   <pubDate>Thu, 23 Dec 2010 12:20:30 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61979&amp;title=record-caching#61979</guid>
  </item> 
  <item>
   <title><![CDATA[Record caching? : thx  vb6? ]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61896&amp;title=record-caching#61896</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2110">Source</a><br /><strong>Subject:</strong> 17570<br /><strong>Posted:</strong> 17 December 2010 at 3:00pm<br /><br />thx<DIV>&nbsp;</DIV><DIV>vb6?</DIV>]]>
   </description>
   <pubDate>Fri, 17 Dec 2010 15:00:38 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61896&amp;title=record-caching#61896</guid>
  </item> 
  <item>
   <title><![CDATA[Record caching? : While I can&amp;#039;t give out the...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61892&amp;title=record-caching#61892</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2657">Algae</a><br /><strong>Subject:</strong> 17570<br /><strong>Posted:</strong> 17 December 2010 at 12:38pm<br /><br />While I can't give out the entire project, the archive construct is fairly simple. Cache is sort of a misnomer because it's not really acting like a true cache.<br><br>Note that if you have enormous amount of records it's going to eat memory proportionally.<br><br>// .h file stuff<br><br>&nbsp;&nbsp;&nbsp; // oldDB is string to name the old records file<br>&nbsp;&nbsp;&nbsp; // newDB is string to name the new records file<br>&nbsp; &nbsp; // aSQL is query cmd string SELECT * FROM etc <br><br>&nbsp;&nbsp;&nbsp; void UpdateRecords(CString oldDB, CString newDB, CString aSQL);<br>&nbsp;&nbsp;&nbsp; CArray &lt;CMemFile*,CMemFile*&gt; cache_files;<br>&nbsp;&nbsp;&nbsp; void _cache(CMemFile *pFile, BOOL bLoad = FALSE);<br><br><br>// .cpp stuff<br>// Cache archive function<br><br>void CReportView::_cache(CMemFile *pFile, BOOL bLoad)<br>{<br>&nbsp;&nbsp; &nbsp;CArchive archive(pFile, bLoad);<br>&nbsp;&nbsp; &nbsp;CXTPPropExchangeArchive px(archive);<br>&nbsp;&nbsp; &nbsp;GetReportCtrl().GetRecords()-&gt;DoPropExchange(&amp;px);<br>&nbsp;&nbsp; &nbsp;archive.Close();<br>&nbsp;&nbsp; &nbsp;pFile-&gt;SeekToBegin();<br>}<br><br>// when program changes database tables do this.<br>//<br>// for performance testing a timer is included in debug build<br>//<br>// CDataHandler is an instance of your database engine. Change it to whatever you use.<br><br>void CReportView::UpdateRecords(CString oldDB, CString newDB, CString aSQL)<br>{<br>&nbsp;&nbsp;&nbsp; DWORD nCount = GetReportCtrl().GetRecords()-&gt;GetCount();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; CDataHandler dh;<br><br>#ifdef _DEBUG<br>&nbsp;&nbsp;&nbsp; DWORD dwTime0 = ::GetTickCount();<br>&nbsp;&nbsp;&nbsp; DWORD dwTime1 = 0;<br>#endif<br><br>&nbsp;&nbsp;&nbsp; // if no records, we assume that it's never been loaded<br>&nbsp;&nbsp;&nbsp; // so load from database<br><br>&nbsp;&nbsp;&nbsp; if (nCount == 0)<br>&nbsp;&nbsp;&nbsp; {<br>// using your database engine, send the query and put results in the report control<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dh.AddRecords(aSQL, GetReportCtrl());<br>#ifdef _DEBUG<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dwTime1 = ::GetTickCount();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TRACE(_T("Load New %s, Operation %.3f sec\n"),newDB, (dwTime1 - dwTime0) / 1000.0);<br>#endif<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>// if we never change tables, this never happens!<br><br>&nbsp;&nbsp;&nbsp; CMemFile *pCache = NULL;<br>&nbsp;&nbsp;&nbsp; BOOL bFound = FALSE;<br><br>&nbsp;&nbsp;&nbsp; // find cache file and save old db records<br><br>&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; cache_files.GetCount(); i++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pCache = cache_files.GetAt(i);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (pCache-&gt;GetFilePath() == oldDB)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; bFound = TRUE;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br><br>// make a new memfile if we need one<br><br>&nbsp;&nbsp;&nbsp; if (!bFound)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pCache = new CMemFile();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pCache-&gt;SetFilePath(oldDB);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cache_files.Add(pCache);<br>&nbsp;&nbsp;&nbsp; }<br><br>// clobber the existing memfile and store current data to it.<br><br>&nbsp;&nbsp;&nbsp; if (pCache != NULL)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pCache-&gt;SetLength(0);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; _cache(pCache,CArchive::store);<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; GetReportCtrl().ResetContent(FALSE);<br><br>&nbsp;&nbsp;&nbsp; bFound = FALSE;<br><br>&nbsp;&nbsp;&nbsp; // find cache file and load it up with a batch of records<br><br>&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; cache_files.GetCount(); i++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pCache = cache_files.GetAt(i);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (pCache-&gt;GetFilePath() == newDB)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; bFound = TRUE;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; // no cache found, we have to go to the database again.<br>&nbsp;&nbsp;&nbsp; if (!bFound)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dh.AddRecords(aSQL, GetReportCtrl());<br>#ifdef _DEBUG<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dwTime1 = ::GetTickCount();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TRACE(_T("Load New %s, Operation %.3f sec\n"),newDB, (dwTime1 - dwTime0) / 1000.0);<br>#endif<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; _cache(pCache,CArchive::load);<br><br>#ifdef _DEBUG<br>&nbsp;&nbsp;&nbsp; dwTime1 = ::GetTickCount();<br>&nbsp;&nbsp;&nbsp; TRACE(_T("Load from Cache %s, Operation %.3f sec\n"),newDB, (dwTime1 - dwTime0) / 1000.0);<br>#endif<br><br>&nbsp;&nbsp;&nbsp; // get modified or new records from everyone else<br>&nbsp;&nbsp;&nbsp; // deleted records handled by storing operation<br>&nbsp;&nbsp;&nbsp; // set time stamp for update<br><br>&nbsp;&nbsp;&nbsp; CString sTime = m_lastTime.Format();<br>&nbsp;&nbsp;&nbsp; aSQL.AppendFormat(_T(" WHERE Created &gt; '%s' OR Modified &gt; '%s'"), sTime, sTime);<br>&nbsp;&nbsp;&nbsp; dh.RefreshRecords(aSQL,GetReportCtrl());<br>}<br>]]>
   </description>
   <pubDate>Fri, 17 Dec 2010 12:38:16 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61892&amp;title=record-caching#61892</guid>
  </item> 
  <item>
   <title><![CDATA[Record caching? : Can you post an example? It will...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61884&amp;title=record-caching#61884</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2110">Source</a><br /><strong>Subject:</strong> 17570<br /><strong>Posted:</strong> 17 December 2010 at 5:33am<br /><br />Can you post an example? It will be good for all!]]>
   </description>
   <pubDate>Fri, 17 Dec 2010 05:33:05 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61884&amp;title=record-caching#61884</guid>
  </item> 
  <item>
   <title><![CDATA[Record caching? : There may be better ways to do...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61873&amp;title=record-caching#61873</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2657">Algae</a><br /><strong>Subject:</strong> 17570<br /><strong>Posted:</strong> 16 December 2010 at 1:10pm<br /><br />There may be better ways to do this, but no one is saying <img src="http://forum.codejock.com/smileys/smiley36.gif" border="0" alt="LOL" title="LOL" /> so I constructed a fairly simple system using CMemFile and serializing the records as a CArchive using property exchange for the records. Its a lot faster than dredging up the records from SQL again and again. Closest thing I've got to virtual records without clobbering the nice sort, group, etc options.<br>]]>
   </description>
   <pubDate>Thu, 16 Dec 2010 13:10:56 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61873&amp;title=record-caching#61873</guid>
  </item> 
  <item>
   <title><![CDATA[Record caching? : That is why I did not renew my...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61439&amp;title=record-caching#61439</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2110">Source</a><br /><strong>Subject:</strong> 17570<br /><strong>Posted:</strong> 18 November 2010 at 5:04am<br /><br />That is why I did not renew my subscription...<br><br>- Virtual mode does not have the same functionality has "normal mode";<br>- Grid control does not exists;<br>- RC databinding is very, very... slow with large recordsets;<br>- Flatedit, date and text controls are ages away from the componentone activex controls designed so many years ago (they are so simple to use and implement) - ex: decimals behavour in a simple control.<br><br>... probably I will by it again :)<br><br><br>]]>
   </description>
   <pubDate>Thu, 18 Nov 2010 05:04:06 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61439&amp;title=record-caching#61439</guid>
  </item> 
  <item>
   <title><![CDATA[Record caching? : That is the problem using Virtual...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61438&amp;title=record-caching#61438</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2110">Source</a><br /><strong>Subject:</strong> 17570<br /><strong>Posted:</strong> 18 November 2010 at 4:58am<br /><br />That is the problem using Virtual Mode... you lose some of the good stuff.<br><br>Working with large recordsets is fine but you do not have this things.<br>Working in "normal mode" with the same large recordsets is too slow but you have the good stuff.<br><br>The best of the 2 worlds - not!<br>]]>
   </description>
   <pubDate>Thu, 18 Nov 2010 04:58:13 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61438&amp;title=record-caching#61438</guid>
  </item> 
  <item>
   <title><![CDATA[Record caching? : Anyone know the best way to cache...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61432&amp;title=record-caching#61432</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2657">Algae</a><br /><strong>Subject:</strong> 17570<br /><strong>Posted:</strong> 17 November 2010 at 8:08pm<br /><br />Anyone know the best way to cache report records in memory so they can be read back into a report control at a later time? Or is it better to write them to disk? Or is either just a bad idea? <br><br>I'd like to use virtual mode but it seems you give up a lot of flexibility doing so (sorting, grouping etc).<br><br>Thanks in advance to anyone who has a suggestion.<br><br><br>]]>
   </description>
   <pubDate>Wed, 17 Nov 2010 20:08:11 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17570&amp;PID=61432&amp;title=record-caching#61432</guid>
  </item> 
 </channel>
</rss>