aboutsummaryrefslogtreecommitdiff
path: root/src/vmod_dict.vcc
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-08-03 22:21:03 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-08-03 22:21:03 +0300
commitc75a811a7734221003ac2628493832acf36b12d5 (patch)
tree8b5a28eaf975f19badf2f9722c15ff2164bff3fb /src/vmod_dict.vcc
parentf9f6ba70f7844321d90476be9bc0bd5ae3e11b45 (diff)
downloadvmod-dict-c75a811a7734221003ac2628493832acf36b12d5.tar.gz
vmod-dict-c75a811a7734221003ac2628493832acf36b12d5.tar.bz2
Serialize write access. Improve API.
* src/vmod_dict.c (entry): Link into a double-linked list. (entry_append, entry_remove): New functions. (max_coll): New static. (locker_t): New type. (locker_init,locker_rlock,locker_wlock) (locker_runlock,locker_wunlock): New functions. (load_entries): Use syslog for diagnostics. Abort if unable to open the file. Fix minor memory leak. (rehash,fill_table): New functions. (dict_event): Handle VCL_EVENT_DISCARD. (vmod_load): Change signature. (vmod_ci,vmod_collisions): New functions. (vmod_clear): New function. * src/vmod_dict.vcc: Update. * tests/ci.at: Accomodate the above changes. * tests/cs.at: Likewise.
Diffstat (limited to 'src/vmod_dict.vcc')
-rw-r--r--src/vmod_dict.vcc30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/vmod_dict.vcc b/src/vmod_dict.vcc
index 76c4267..5e80a02 100644
--- a/src/vmod_dict.vcc
+++ b/src/vmod_dict.vcc
@@ -9,17 +9,33 @@ or a pair of keyword - value separated by one or more whitespace characters.
Leading and trailing whitespace is discarded. Comments are introduced by a
hash sign at the beginning of the line. Empty lines and comments are ignored.
-$Function VOID load(STRING file, BOOL ci, INT ncls)
+$Event dict_event
+$Function VOID ci(BOOL v)
Description
- Loads key/value dictionary from **file** into memory. The **ci**
- parameter controls whether key lookups should be case-insensitive.
- The **ncls** parameter, if positive, gives the maximum allowable length
- of collision chain in the hash table. The module will adjust the hash
- load factor to ensure thes number of collisions doesn't exceed this
- value.
+ If **v** is **true**, sets case-insensitive string comparison. Default is
+ case-sensitive comparison.
+
+$Function VOID collisions(INT n)
+
+Description
+ Sets the maximum allowable length of collision chain in the hash table.
+ Negative value of **n** means unlimited length. Otherwise, the module will
+ adjust the hash table load factor to ensure the number of collisions
+ doesn't exceed **n**.
+
+$Function VOID load(STRING file)
+
+Description
+ Loads key/value dictionary from **file** into memory. The **file** must
+ exist and be readable for the user varnish runs as.
This function is normally called from **vcl_init**.
+
+$Function VOID clear()
+
+Description
+ Clears entire dictionary.
$Function STRING lookup(STRING key)

Return to:

Send suggestions and report system problems to the System administrator.