SQUID Functions

 

  • The SQUID functions, and their examples, assume that the SQUID server has been started with an address of http://localhost:8000.
  • Validation of the function calls can be handled by checking the return value and calling SquidGetLastError().

 

Thursday
Feb212013

SquidResume

  • Resumes the updating of SQUID.
  • All cached information will be written to SQUID and be available to all users.
  • Calls SquidRefresh.

Prototype

int SquidResume(int iSquid, char* sParam);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

// SquidSendData 10000 times, wrapped in SquidPause/SquidResume calls and
// calling SquidRefresh every 1000 sends.
int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidPause (iSquid, "col");
for (i=1; i<=10000; i++)
{
if (i==5000)
{
lr_output_message("dirty=%d", SquidIsDirty(iSquid,"col"));
}
sprintf (strBuffer, "LR-SEND3-%03d-%05d", iVuserId, i);
SquidSendData (iSquid, "col", strBuffer);
if (i % 1000 == 0)
{
SquidRefresh (iSquid, "col");
}
if (i==5000)
{
lr_output_message("dirty=%ld", SquidIsDirty(iSquid,"col"));
}
}
SquidResume (iSquid, "col");
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidRetrieveData

  • Retrieves and clears the first data element from a column in SQUID.

Prototype

char* SquidRetrieveData(int iSquid, char* sParam);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
  • Return Values
char*Operation successful, data element retrieved
""Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "Data Row 1");
SquidSendData(iSquid, "NewColumn", "Data Row 2");
SquidSendData(iSquid, "NewColumn", "Data Row 3");
SquidRetrieveData(iSquid, "NewColumn");
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidSendData

  • Sends data into the next row of a column in SQUID.
  • If the column does not exist, it will be created and the data will be added.

Prototype

int SquidSendData(int iSquid, char* sParam, char* sData);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
sDataThe data to send to the column
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "Data Row 1");
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidSendDataIfUnique

  • Sends data into a column in SQUID, provided that the value does not already exist.
  • If the column does not exist, it will be created and the data will be added.

Prototype

int SquidSendDataIfUnique(int iSquid, char* sParam, char* sData);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
sDataData to send to the column
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

char sBuf[100];
int iRandom;
int i;
int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
srand(time(NULL));
for (i=1; i<= 100; i++)
{
   iRandom = (rand() % 100) + 1;
   sprintf(sBuf, "LR-%05d", iRandom);
   SquidSendDataIfUnique(iSquid, "NewColumn", sBuf);
}
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidUpdateData

  • Update data at the given column and index.

Prototype

int SquidUpdateData(int iSquid, char* sParam, int iIndex, char* sData);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
iIndexRow index to update (1-based)
sDataThe updated data
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "Data Row 1");
SquidSendData(iSquid, "NewColumn", "Data Row 2");
SquidSendData(iSquid, "NewColumn", "Data Row 3");
SquidUpdateData(iSquid, "NewColumn", 2, "New Data Row 2");
SquidDisconnect(iSquid);

Page 1 2