GetItemsFromMemory(
[Destkey: Integer = -1;]
[ParamValues: IMetabaseObjectParamValues: = Null]): ICubeCacheItems;
Destkey. The key of cube display version.
ParamValues. Parameter values set.
The GetItemsFromMemory method, according to the specified parameters, gets cache instances from computer RAM.
Cache is saved to computer RAM if the cube is calculated in the lock support mode - CubeInstanceDestinationExecutorOptions.RWMutex.
Executing the example requires a standard cube with the STD_CUBE identifier.
Add links to the Cubes, Dimensions, Matrix, Metabase system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
MDesc, CacheDesc: IMetabaseObjectDescriptor;
CubeInst: ICubeInstance;
CubeDest: ICubeInstanceDestination;
SelSet: IDimSelectionSet;
Sel: IDimSelection;
Executor: ICubeInstanceDestinationExecutor;
Matr: IMatrix;
CacheSaver: ICubeCacheSaver;
Items: ICubeCacheItems;
Begin
MB := MetabaseClass.Active;
MDesc := MB.ItemById("STD_CUBE");
// Open cube
CubeInst := MDesc.Open(Null) As ICubeInstance;
CubeDest := CubeInst.Destinations.DefaultDestination;
SelSet := CubeDest.CreateDimSelectionSet;
// Full selection by all dimensions
For Each Sel In SelSet Do
Sel.SelectAll;
End For;
// Prepare and calculate cube
Executor := CubeDest.CreateExecutorO(CubeInstanceDestinationExecutorOptions.RWMutex);
Executor.PrepareExecute(SelSet);
Executor.PerformExecute;
// Output matrix with data
Matr := Executor.Matrix;
CacheDesc := GetCache(MDesc);
If CacheDesc <> Null Then
CacheSaver := CacheDesc.Bind As ICubeCacheSaver;
// Save matrix to cache
CacheSaver.SaveCacheCustom(CubeDest.Key, Null, SelSet, Matr, "Full selection");
// Cache instances in memory
Items := CacheSaver.GetItemsFromMemory;
ShowCacheItems(Items);
End If;
End Sub UserProc;
Function GetCache(MObj: IMetabaseObjectDescriptor): IMetabaseObjectDescriptor;
Var
Desc: IMetabaseObjectDescriptor;
Begin
For Each Desc In MObj.Children Do
If Desc.ClassId = MetabaseObjectClass.KE_CLASS_CUBE_CACHE_SAVER Then
Return Desc;
End If;
End For;
Return Null;
End Function GetCache;
Sub ShowCacheItems(Items: ICubeCacheItems);
Var
Item: ICubeCacheItem;
DimSS: IDimSelectionSet;
DimS: IDimSelection;
i, c: Integer;
Begin
Debug.WriteLine("Number of cache instances: " + Items.Count.ToString);
c := Items.Count;
For i := 0 To c - 1 Do
Item := Items.Item(i);
Debug.WriteLine("Cache instance hash code: " + Item.Hash + ". Last modified: " + Item.Date.ToString);
Debug.Write("Display version (key): " + Item.DestinationKey.ToString + ". " +
"Custom label: " + Item.CustomValue);
If IsNull(Item.ParamValues) = False Then
Debug.WriteLine(". Parameters: " + Item.ParamValues.Count.ToString + '.');
Else
Debug.WriteLine(". No parameters.");
End If;
End For;
DimSS := Item.SelectionSet;
Debug.WriteLine("Selection, by which cache instance was saved.");
Debug.WriteLine("Dimensions:");
Debug.Indent;
For Each DimS In DimSS Do
Debug.WriteLine(DimS.Dimension.Name + ". Selected: " + DimS.SelectedCount.ToString);
End For;
Debug.Unindent;
End Sub ShowCacheItems;
After executing the example, the cube is calculated by full selection in the matrix lock mode with results. After the calculation the obtained matrix will be saved to cache. Cached data will also be loaded to the computer RAM. Information about cache instances from the RAM will be displayed in the development environment console.
See also: