Documentation Cacheable Tables: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
== generate cached tables ==
== Overview: Cacheable DataTables ==
Cacheable Tables are generated with:
See [[Overview_openPETRA_architecture#Data_Caching|Data Caching]] in the architectural overview of openPETRA.
 
== Generate Cacheable DataTables ==
Cacheable DataTables are generated with:
  nant generateORMCachedTables
  nant generateORMCachedTables


== define cached tables and lists ==
== Defining cached tables and lists ==
You can define in the file csharp/ICT/Petra/Definitions/CacheableTablesAndLists.yaml which tables or lists should be cached.
The file csharp/ICT/Petra/Definitions/CacheableTablesAndLists.yaml contains DB tables and lists which should be cached.


All cached tables are defined in one file. The first level is the module, the next deeper level is the submodule.  
All cached tables are defined in this one file. The first level is the module, the next deeper level is the submodule.  
After that, there is a different section for either tables that are straight from the database ('''DatabaseTables''', eg. PMethodOfContact), and lists that are calculated with SQL or have added columns ('''CalculatedLists''', eg. CountryListFromExistingLocations).
After that, there is a different section for either tables that are straight from the database ('''DatabaseTables''', eg. PMethodOfContact), and lists that are calculated with SQL or have added columns ('''CalculatedLists''', eg. CountryListFromExistingLocations).


Line 14: Line 17:
* '''DependsOnLedger''': This is used for most finance tables because you only want to cache values of a specific ledger. This attribute can be defined on an element higher up in the yaml hierarchy and is inherited for all lower lines.
* '''DependsOnLedger''': This is used for most finance tables because you only want to cache values of a specific ledger. This attribute can be defined on an element higher up in the yaml hierarchy and is inherited for all lower lines.


== files affected by the generation of cached tables ==
== Files affected by the generation of Cacheable DataTables ==
* in Petra/Shared, for each module there is a Petra/Shared/lib/M<Module>/Cacheable.cs file autogenerated
* in Petra/Shared, for each module there is a Petra/Shared/lib/M<Module>/Cacheable.cs file autogenerated
* in Petra/Server, for each submodule there is a file autogenerated in Petra/Server/lib/M<Module>/<Submodule>.Cacheable.cs. If there is only one submodule, then the submodule name might be ommitted from the filename.
* in Petra/Server, for each submodule there is a file autogenerated in Petra/Server/lib/M<Module>/<Submodule>.Cacheable.cs. If there is only one submodule, then the submodule name might be ommitted from the filename.
Line 23: Line 26:
You also need to add using clauses to the top of the Server Cacheable files, inside a ManualCode section.
You also need to add using clauses to the top of the Server Cacheable files, inside a ManualCode section.


== Updating/Invalidating a cached table ==
== Updating/Invalidating a Cacheable DataTable ==
When data gets changed, then the cached table needs to be marked as invalid.
When data gets changed, then the cached table needs to be marked as invalid.


  refer to Ict.Petra.Shared.dll, for CacheableTablesManager
  reference 'Ict.Petra.Shared.dll' (for TCacheableTablesManager Class)
   
   
  using Ict.Petra.Server.App.ClientDomain;
  using Ict.Petra.Server.App.ClientDomain;

Revision as of 14:44, 8 November 2010

Overview: Cacheable DataTables

See Data Caching in the architectural overview of openPETRA.

Generate Cacheable DataTables

Cacheable DataTables are generated with:

nant generateORMCachedTables

Defining cached tables and lists

The file csharp/ICT/Petra/Definitions/CacheableTablesAndLists.yaml contains DB tables and lists which should be cached.

All cached tables are defined in this one file. The first level is the module, the next deeper level is the submodule. After that, there is a different section for either tables that are straight from the database (DatabaseTables, eg. PMethodOfContact), and lists that are calculated with SQL or have added columns (CalculatedLists, eg. CountryListFromExistingLocations).

You can define the following attributes:

  • Comment: if you don't want the default description from petra.xml to be used in the enum comment in Shared, you can define your own comment here. You definitely should add a comment for all calculated lists since there is no default comment for them.
  • Enum: if the enum name should not be calculated from the table name (PMethodOfContact would become MethodOfContactList), you can specify an explicit enum name. eg. CurrencyCodeList for ACurrency
  • DependsOnLedger: This is used for most finance tables because you only want to cache values of a specific ledger. This attribute can be defined on an element higher up in the yaml hierarchy and is inherited for all lower lines.

Files affected by the generation of Cacheable DataTables

  • in Petra/Shared, for each module there is a Petra/Shared/lib/M<Module>/Cacheable.cs file autogenerated
  • in Petra/Server, for each submodule there is a file autogenerated in Petra/Server/lib/M<Module>/<Submodule>.Cacheable.cs. If there is only one submodule, then the submodule name might be ommitted from the filename.

ManualCode adjustments

For lists, you need to define how to calculated and fill the lists. Please find the Get...Table() functions at the bottom of the Server Cacheable file.

You also need to add using clauses to the top of the Server Cacheable files, inside a ManualCode section.

Updating/Invalidating a Cacheable DataTable

When data gets changed, then the cached table needs to be marked as invalid.

reference 'Ict.Petra.Shared.dll' (for TCacheableTablesManager Class)

using Ict.Petra.Server.App.ClientDomain;

DomainManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
    TCacheableFinanceTablesEnum.AccountList.ToString());