caching IBObjects
$30-5000 USD
Pagado a la entrega
a large application uses IBOBjects to load/store data into Firebird 1.5
Apart from TIBODatabase, all the work is done by TIBOQuery.
We want to add cache ability to TIBOQuery.
We will have the following new components:
TIBODatabase_=class(TIBODatabase)
public
property CacheEnabled:boolean; // will enable caching for all queries
end;
TIBOQuery_=class(TComponent)
protected
qry:TIBOQuery;
esy:TEasyTable;
function GetHash:string;
procedure CreateCacheFile;
public
property Database:TIBODatabase_;
procedure Open;
procedure ExecSQL;
constructor Create(aOwner:TComponent); override;
destructor Destroy; override;
// all main methods of a TDataset here
end;
constructor [login to view URL](aOwner:TComponent);
begin
inherited;
qry:=[login to view URL](self);
esy:=[login to view URL](self);
end;
procedure [login to view URL];
begin
(*
pseudocode:
0. if cache disabled, call inherited code
1. if SELECT, check is the query is in the cache
2. if so, return what is in the cache
3. else
begin
call inherited code
CreateCacheFile;
end;
*)
if Pos('UPDATE',Uppercase([login to view URL]))>0 then
dataset:=qry
else if Pos('DELETE',Uppercase([login to view URL]))>0 then
dataset:=qry
else if Pos('INSERT',Uppercase([login to view URL]))>0 then
inherited Open
else if Pos('OPEN',Uppercase([login to view URL]))>0 then
begin
hash:=GetHash;
if FileExists(hash) then
LoadFromCacheFile;
end
end;
function [login to view URL]:string;
begin
(*
will return a hash depending on prepared SQL.Text. The hash will be different when
the same SQL text is fed with
The hash string is created such that it will be easy to get a list of
of all cache files that depend on table X just by looking at the hash names.
Also the current day should go into the string, so that it will be easy
to filter all hash names created before date T
*)
end;
procedure [login to view URL];
var
FileName:string;
begin
(*
FileName:=GetHash;
// the hash depends on the sql text
CreateTmpTable;
// create a temporary table of type TEasyTable having the same fields
// as the current query
FillTmpTable;
// copy data from the current query into the temporary table
SaveTmpTable;
// save the temporary table to the cache directory using FileName
*)
end;
## Deliverables
We won't handle caching aging and deleting here. The coder will provide a test EXE. I should be able to get caching just replacing TIBOQuery with TIBOQuery_ in the large application.
Nº del proyecto: #2857246