17.05.2007, 20:01 | #1 |
Banned
|
Развивающая игра с xRecord.wasCached(), RecordViewCache
Многие опытные разработчики думают о кешировании записей и выполняют соответствующие действия "про запас", не имея времени проверить, работает ли кеш, или не зная, как это можно проверить.
Коллега нашел решение: метод xRecord.wasCached(). Предлагаю всем желающим самостоятельно протестировать и проанализировать следующий код (для 4.0, если это имеет значение): X++: static server void testCaching() // try to call on the client { SalesLine salesLine, salesLineRVC; RecordViewCache rvc; #DEFINE.TestInventTransId('08587_059') void showInfo(str _desc, SalesLine _salesLine) { ; setPrefix(_desc); info(strFmt("InventTransId = '%1', .wasCached() = '%2'.", _salesLine.InventTransId, _salesLine.wasCached())); } ; new Application().flushcompanycache(curExt()); // try to comment this out and start a couple of times Dictionary::dataFlush(salesLine.TableId); // "-" info("All caches have been flushed"); select firstonly salesLine where salesLine.InventTransId == #TestInventTransId; showInfo("1. A select over an indexed field", salesLine); select firstonly salesLine where salesLine.InventTransId == #TestInventTransId; showInfo("2. The same select", salesLine); ttsbegin; select firstonly salesLine where salesLine.InventTransId == #TestInventTransId; showInfo("3. The same select as the 1 and 2, but in TTS", salesLine); ttsabort; select firstonly salesLine where salesLine.InventTransId == #TestInventTransId && salesLine.ConfirmedDlv <= systemDateGet(); showInfo("4. A slightly different select over a non-index field", salesLine); select firstonly salesLine where salesLine.InventTransId == #TestInventTransId && salesLine.ConfirmedDlv <= systemDateGet(); showInfo("5. The same as 4, called the 2nd time", salesLine); select firstonly nofetch salesLineRVC where salesLineRVC.InventTransId == #TestInventTransId; rvc = new RecordViewCache(salesLineRVC); select firstonly salesLine where salesLine.InventTransId == #TestInventTransId && salesLine.ConfirmedDlv <= systemDateGet(); showInfo("6. The same as 4 and 5, but after an RVC has been instantiated", salesLine); } Цитата:
All caches have been flushed
1. A select over an indexed field InventTransId = '08587_059', .wasCached() = 'NotCached'. 2. The same select InventTransId = '08587_059', .wasCached() = 'RecordCached'. 3. The same select as the 1 and 2, but in TTS InventTransId = '08587_059', .wasCached() = 'NotCached'. 4. A slightly different select over a non-index field InventTransId = '08587_059', .wasCached() = 'NotCached'. 5. The same as 4, called the 2nd time InventTransId = '08587_059', .wasCached() = 'NotCached'. 6. The same as 4 and 5, but after an RVC has been instantiated InventTransId = '08587_059', .wasCached() = 'ViewCached'. Последний раз редактировалось EVGL; 17.05.2007 в 20:04. |
|
|
За это сообщение автора поблагодарили: glibs (2), kashperuk (18), Logger (2), Kabardian (2). |