diff options
Diffstat (limited to 'doc/vmod-dbrw.3')
-rw-r--r-- | doc/vmod-dbrw.3 | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/doc/vmod-dbrw.3 b/doc/vmod-dbrw.3 index 6f1dba8..4760b6b 100644 --- a/doc/vmod-dbrw.3 +++ b/doc/vmod-dbrw.3 @@ -1,5 +1,5 @@ .\" This file is part of Vmod-dbrw -*- nroff -*- -.\" Copyright (C) 2013-2017 Sergey Poznyakoff +.\" Copyright (C) 2013-2018 Sergey Poznyakoff .\" .\" Vmod-dbrw is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ .\" .\" You should have received a copy of the GNU General Public License .\" along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>. -.TH VMOD-DBRW 1 "January 30, 2018" "VMOD-DBRW" "User Reference" +.TH VMOD-DBRW 1 "December 8, 2018" "VMOD-DBRW" "User Reference" .SH NAME vmod-dbrw \- Database-driven rewrite rules for Varnish Cache .SH SYNOPSIS @@ -134,6 +134,32 @@ form can be used in contexts where the variable name is immediately followed by another letter, to prevent it from being counted as a part of the name. .PP +The special construct +.sp +.EX +$(urlprefixes \fIPATH\fR) +.EE +.sp +expands to a comma-separated list of all possible path prefixes in +\fIPATH\fR. Each element in the list is quoted, so the result can +safely be used in SQL statements. For example, +.sp +.EX +$(urlprefixes "/local/user/login") +.EE +.sp +produces +.sp +.EX + '/local/user/login','/local/user','/local' +.EE +.PP +This statement is usually used in \fBIN\fR SQL constructs, e.g. +.sp +.EX +SELECT * FROM table WHERE url IN ($(urlprefixes $url)) +.EE +.PP The expanded query is then sent to the database server. Handling of the return value depends on the number of fields it contains. .SS Strict matches @@ -248,7 +274,9 @@ sub vcl_recv { # wildcard pattern. dbrw.config("mysql", "database=varnish;user=varnish;debug=10", {"SELECT dest,pattern,value,flags FROM rewrite - WHERE host='$host' and '$url' like url"}); + WHERE host='$host' + AND url IN ($(urlprefixes $url)) + ORDER BY LENGTH(dest),value DESC"}); set req.http.X-Redirect-To = dbrw.rewrite("host=" + req.http.Host + ";" + "url=" + req.url); |