DCache
DCache - Cache for DataSet
- Quiet · last change 9-26-2024
- ★ 2 on GitHub
README

📖 Description
Idea found here https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match
The purpose of using DCache is to perform queries on the database only if there is a change in the data set. Explanation: every time the information "Not modified" is displayed, it means that there was no search in the database, and when it displays "Modified", it actually performed the search in the database. As shown below

🛠️ The Class
Type
TCache = class
strict private
class var Cache: TCache;
private
FModified: boolean;
FHashData: String;
FHashCache: String;
procedure SetModified(const Value: boolean);
procedure SetHashData(const Value: String);
public
function CalculatetHash(DataSet: TDataSet): String;
function IsModified: boolean;
class function SetDataSet(Const StoreHash: Boolean; DataSet: TDataSet) :TCache;
class function Compare(DataSet: TDataSet) :TCache;
class function GetInstance : TCache;
property Modified: boolean read IsModified write SetModified default False;
property HashData: String read FHashData write SetHashData;
end;✅ Starting and SetDataSet
Begin
TCache.GetInstance.SetDataSet(True,QueryGrid);
End;✅ Checking if there was a change in the data set, if there was, perform the query, otherwise, it does nothing.
if TCache.GetInstance
.Compare(QueryGrid)
.IsModified then💬 Contributions / Ideas / Bug Fixes
To submit a pull request, follow these steps:
- 🍴 Fork the project.
- 🌿 Create a new branch (
git checkout -b my-new-feature). - 🛠️ Make your changes.
- 💾 Commit your changes (
git commit -am 'Add new feature or fix bug'). - 📤 Push the branch (
git push origin my-new-feature). - 🔄 Open a pull request.
Give me a Star ⭐⭐⭐⭐⭐.

