Question
· Aug 6, 2021

Cache routines: Date and Time Saved vs. Date and Time Modified

My objective is to find routine's Date/Time Saved someplace inside Cache. The routine's Date/Time Modified as returned by various queries like %Library.RoutineIndex and as seen on the File Open screen is actually Date/Time Compiled last, not Date/Time Saved last. Does anyone know if Date/Time Saved is created when the Save icon is pressed or the routine is imported? Such a timestamp should be immune to subsequent compilations with no changes.

I am also curious about the internal Cache mechanism that marks the routine's tab with + which means saved but not compiled yet. Does it compare some invisible timestamp Saved with the timestamp Compiled?

Product version: Caché 2017.1
Discussion (5)1
Log in or sign up to continue

Give the ^rINDEX global a look.

I made a QTEST routine in Studio, and saved it but did not compile it.

QTEST ; JUST A TEST.
 Q
EN ; JUST A TEST.
 Q
 ;

and then I executed this at the programmer prompt:

ZW ^rINDEX("QTEST")
^rINDEX("QTEST","INT")=$lb("2021-08-06 13:21:58.061867",49)

I changed the routine a bit:

QTEST ; JUST A BIGGER TEST.
 Q
EN ; JUST A BIGGER TEST.
 Q
 ;

and I ZW'd the global again:

ZW ^rINDEX("QTEST")
^rINDEX("QTEST","INT")=$lb("2021-08-06 13:24:50.38743",63)

It may be safe to assume that the underlined parameter is the length or number of bytes of storage required.

Now once I compile the routine in Studio, and ZW the global again, this is the output:

ZW ^rINDEX("QTEST")
^rINDEX("QTEST","INT")=$lb("2021-08-06 13:24:50.38743",63)
^rINDEX("QTEST","OBJ")=$lb("2021-08-06 13:26:30",152)

Hope this helps!

Class Documentation of %Library.RoutineIndex tells me:
property Type as %String [ Required ];

The type of routine, this will be one of:
  • MAC - Macro routine, content is stored in ^rMAC global
  • INT - ObjectScript routine, content is stored in ^ROUTINE global
  • INC - Include file, these may be included from a MAC routine, content is stored in ^rINC
  • BAS - Cache Basic routine, content is stored in the ^ROUTINE global
  • MVB - MultiValue Basic routine, content is stored in the ^ROUTINE global
  • OBJ - Object code, content is stored in ^rOBJ global

Class Documentation of %Library.Routine explains the storage and  tells me: 
• classMethode GetRoutineGlobals(ByRef Names As %String) as %Status

Return list of globals where routine and class information is stored.
Returns Names="ROUTINE,rBACKUP,rINC,rINCSAVE,rINDEX,rMAC,rMACSAVE,rMAP,rOBJ,oddDEF"
Here is some documentation on the format of the routine globals. ROUTINE - Native .INT COS code, generated from .MAC, or generated from classes. When compiled generates .OBJ code.
ROUTINE(Name,0)=timestamp when last saved
ROUTINE(Name,0,0)=# lines in routine
ROUTINE(Name,0,1...x) = Source Lines in routine
ROUTINE(Name,0,"GENERATED")= 0/1 whether routine is generated or native
ROUTINE(Name,0,"INC",IncludeFileName1)=Timestamp when last include file last saved
ROUTINE(Name,0,"INC",IncludeFileName2)=Timestamp when last include file last saved
ROUTINE(Name,0,"SIZE")=# bytes in routine
ROUTINE(Name,0,"LANG")=language mode ROUTINE(Name,"MAC")=Timestamp of .MAC code when last saved if generated
rBACKUP(Name,Type,version) - backup of ^ROUTINE, created by the command Merge ^rBACKUP(rtn,type,nextverersion)=^ROUTINE(rtn) where type="INT/MVI/BAS" rINC - Native .INT or macro code, compiled into .MAC when included with #include directive
rINC(Name,0)=timestamp when last saved
rINC(Name,0,0)=# lines in include file
rINC(Name,0,1...x) = Source Lines in include file
rINC(Name,0,"SIZE")=# bytes in include file
rINC("ZZ","P") - Meta data used for precompiling include files rINCSAVE - Backup of ^rINC, created by the command Merge ^rINCSAVE(rtn,nextver)=^rINC(rtn,0) rINDEX - Index of .OBJ, .INT, and .MAC routines
rINDEX(Name,"OBJ/MAC/INC")=$lb(Time compiled,Size)
rINDEX(Name,"INT")=$lb(Time compiled,Size,Generated 0/1) rMAC - Native .MAC Macro code which when compiled generates .INT code
rMAC(Name,0)=Timestamp when last saved
rMAC(Name,0,0)=#lines in routine
rMAC(Name,0,1...x) = Source Lines in routine
rMAC(Name,0,"SIZE")=# bytes in routine rMACSAVE(Name,Type,version) - backup of ^rMAC, created by the command Merge ^rMACSAVE(rtn,nextver)=^rMAC(rtn,0) rMAP - Debug map used by the debugger and for error trapping
rMAP(Name,"INT","MAC",offsets)=$lb(debuginfo)
rMAP(Name,"MAC","INT",offsets)=$lb(debuginfo) rOBJ - Compiled .INT code
rOBJ(Name,"INT")=timestamp of .INT code when compiled
rOBJ(Name,0...n)=Compiled object code oddDEF - Source code for classes
oddDEF($zcvt(Name,"U"),....)=source code from class. Note that all of the other odd* nodes are meta data describing the class, and can be recreated by compiling the class. The rINDEXCLASS and rINDEXSQL nodes also get recreated when compiling the class.

so you may either do a query or just look into the globals directly
the sequence MAC        -> INT           -> OBJ      is
equivalent to modified -> modified - > compiled