Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
81913d93
Commit
81913d93
authored
Sep 01, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add obj.age and beresp.age VCL variables
parent
bf1fd868
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletion
+38
-1
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+16
-0
r00956.vtc
bin/varnishtest/tests/r00956.vtc
+8
-0
generate.py
lib/libvcc/generate.py
+14
-1
No files found.
bin/varnishd/cache/cache_vrt_var.c
View file @
81913d93
...
...
@@ -536,6 +536,22 @@ VRT_DO_EXP_R(beresp, ctx->bo->fetch_objcore->exp, grace, 0)
VRT_DO_EXP_L
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
keep
,
0
)
VRT_DO_EXP_R
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
keep
,
0
)
/*--------------------------------------------------------------------
*/
#define VRT_DO_AGE_R(which, sexp) \
\
double \
VRT_r_##which##_##age(const struct vrt_ctx *ctx) \
{ \
\
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
return(ctx->now - sexp.t_origin); \
}
VRT_DO_AGE_R
(
obj
,
ctx
->
req
->
objcore
->
exp
)
VRT_DO_AGE_R
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
)
/*--------------------------------------------------------------------
* [be]req.xid
*/
...
...
bin/varnishtest/tests/r00956.vtc
View file @
81913d93
...
...
@@ -10,12 +10,15 @@ varnish v1 -vcl+backend {
set beresp.http.fooA = beresp.ttl;
set beresp.ttl = 10s;
set beresp.http.fooB = beresp.ttl;
set beresp.http.ageA = beresp.age;
}
sub vcl_hit {
set req.http.foo = obj.ttl;
set req.http.ageB = obj.age;
}
sub vcl_deliver {
set resp.http.foo = req.http.foo;
set resp.http.ageB = req.http.ageB;
}
} -start
...
...
@@ -25,6 +28,7 @@ client c1 {
expect resp.bodylen == 40
expect resp.http.fooA == 19.000
expect resp.http.fooB == 10.000
expect resp.http.ageA == 4.000
delay 2
txreq
...
...
@@ -33,6 +37,8 @@ client c1 {
expect resp.http.fooA == 19.000
expect resp.http.fooB == 10.000
expect resp.http.foo <= 8.000
expect resp.http.ageA == 4.000
expect resp.http.ageB >= 6.000
delay 2
txreq
...
...
@@ -41,4 +47,6 @@ client c1 {
expect resp.http.fooA == 19.000
expect resp.http.fooB == 10.000
expect resp.http.foo <= 6.000
expect resp.http.ageA == 4.000
expect resp.http.ageB >= 8.000
} -run
lib/libvcc/generate.py
View file @
81913d93
...
...
@@ -468,7 +468,13 @@ sp_variables = [
(
'backend_response'
,
'backend_error'
),
(
'backend_response'
,
'backend_error'
),
"""
The object's remaining time to live, in seconds.
beresp.ttl is writable.
"""
),
(
'beresp.age'
,
'DURATION'
,
(
'backend_response'
,
'backend_error'
),
(
),
"""
The age of the object.
"""
),
(
'beresp.grace'
,
...
...
@@ -553,6 +559,13 @@ sp_variables = [
The object's remaining time to live, in seconds.
"""
),
(
'obj.age'
,
'DURATION'
,
(
'hit'
,
),
(
),
"""
The age of the object.
"""
),
(
'obj.grace'
,
'DURATION'
,
(
'hit'
,
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment