Sitecore Core Development

Friday, November 04, 2005

IDTable

Sitecore 5.1.1 contains a new feature called IDTable.

The purpose of IDTable is to provide DataProvider developers with a map between arbitrary keys and IDs that can be used in Sitecore. For instance, the FileSystem DataProvider uses the full path of a file as key.

The IDTable persists the relation between the key and the ID, so that a key always returns the same ID.

The API of IDTable is very simple:

public static IDTableEntry Add(string prefix, string key, ID id) {
public static IDTableEntry Add(string prefix, string key, ID id, ID parentID) {
public static IDTableEntry Add(string prefix, string key, ID id, ID parentID, string customData) {
public static IDTableEntry GetID(string prefix, string key) {
public static IDTableEntry[] GetKeys(string prefix, ID id) {
public static IDTableEntry GetNewID(string prefix, string key) {
public static IDTableEntry GetNewID(string prefix, string key, ID parentID) {
public static IDTableEntry GetNewID(string prefix, string key, ID parentID, string customData) {
public static void RemoveID(string prefix, ID id) {
public static void RemoveKey(string prefix, string key) {

Most of the functions operate on the IDTableEntry class. This class has 5 properties:
string Prefix
string Key
ID ID
ID ParentID
string CustomData

The prefix is an identifier that all keys are prefixed with. In the FileSystem database this prefix should be "FileSystem". The ParentID property can be used if the DataProvider does not have an intrinsic parent/child relation like the FileSystem have, for instance a Customer/Order releation is an SQL database. The CustomData is a user-defined property.

IDTable is implemented as a provider model. Sitecore supplies default implementations for all database providers: SQL Server, Firebird and Oracle.

To configure IDTable, add the following section to the web.config:


<IDTable type="Sitecore.Data.IDTables.SqlIDTable,Sitecore.SqlServer">
<param desc="connection" ref="connections/master" />
<param desc="cacheSize">500KB</param>
</IDTable>

This setup enables IDTable to run on the SQL Server table in the Master database.

16 Comments:

Post a Comment

<< Home