Recently a requirement came up to be able to fast purge squid entries by
URL matching.
So I embarked apon this today. After getting all my installations on
Linux/Solaris up.
I had some trouble following the code but ended up with some reasonable
code for dumping and linearly processing the entire cache, client/server
buy adding to the client_side.c and store.c.
Although I will probably figure it out I thought it might be good to
send an email so someone can critique this code.
Since I am unsure of the considerations for locking, swapping in/out of
memory of StoreEntry's. (Basically I don't have a technical overview of
the system and I am piecing it together.)
Here is an excert of a linear regex purge (I will adapt DB2 BTree's to
make this very fast later) and we will donate it back to all.
This seems to work but there is no housekeeping. Can someone critique
it with the missing locks/swap in if it isn't in memory logic.
void
storeDump() {
hash_link *walker;
int i=0;
debug(20, 2) ("Dumping the persistent store walker=%p\n",walker);
hash_first(store_table);
walker = hash_next(store_table);
for (; walker; walker = hash_next(store_table),i++) {
debug(20, 2) ("Item (%5d)\n",i);
storeEntryDump((StoreEntry *) walker,2);
assert(walker != walker->next);
}
}
void
storeRemoveRegex(const char *regex) {
hash_link *walker;
int i=0;
regex_t compare;
regmatch_t pmatch;
debug(20, 2) ("storeRemoveRegex: Constructing Regex with %s\n",regex);
int code = regcomp(&compare, regex, REG_EXTENDED | REG_ICASE | REG_NEWLINE);
if(!code) {
debug(20, 2) ("storeRemoveRegex: Constructing Regex Done\n");
debug(20, 2) ("storeRemoveRegex: Finding first entry\n");
hash_first(store_table);
debug(20, 2) ("storeRemoveRegex: Finding first entry done\n");
debug(20, 2) ("storeRemoveRegex: Finding initial entry\n");
walker=hash_next(store_table);
debug(20, 2) ("storeRemoveRegex: Finding initial entry done (%p)\n",walker);
debug(20, 2) ("storeRemoveRegex: Entering Loop\n");
while(walker) {
debug(20, 2) ("storeRemoveRegex: Start Loop block with %p\n",walker);
StoreEntry *store_entry = (StoreEntry *) walker;
if(store_entry->mem_status == NOT_IN_MEMORY) {
debug(20, 2) ("storeRemoveRegex: The Entry object was null doing persistence retrieval\n");
<WHAT SHOULD GO HERE>
debug(20, 2) ("storeRemoveRegex: The Entry object retrieved has pointer %p\n", store_entry->mem_obj);
}
debug(20, 2) ("storeRemoveRegex: Executing regex match on %s",storeUrl(store_entry));
if(!regexec(&compare, storeUrl(store_entry),1, &pmatch,0)) {
storeLockObject(store_entry);
debug(20, 2) ("storeRemoveRegex: Releasing Item (%5d) from the store:\n",i);
storeEntryDump(store_entry,2);
storeRelease(store_entry);
}
debug(20, 2) ("storeRemoveRegex: Executing regex match finished\n");
walker = hash_next(store_table);
i++;
debug(20, 2) ("storeRemoveRegex: End Loop block with next %p\n",walker);
assert(walker != walker->next);
}
regfree(&compare);
} else {
debug(20, 2) ("storeRemoveRegex: Regex creation failed with return code %i\n",code);
}
}
Received on Thu May 05 2005 - 17:57:28 MDT
This archive was generated by hypermail pre-2.1.9 : Tue May 31 2005 - 12:00:03 MDT