summaryrefslogtreecommitdiffstats
path: root/docs/manual/mod/mod_lua.xml
diff options
context:
space:
mode:
authorDaniel Gruno <humbedooh@apache.org>2013-04-21 09:12:27 +0200
committerDaniel Gruno <humbedooh@apache.org>2013-04-21 09:12:27 +0200
commit16c5c09faba96fc09f6295bb42a3cb8f6a10c7fc (patch)
tree3a6800005e6d5b29cae9b6e9d1d33095b24619dc /docs/manual/mod/mod_lua.xml
parentremove backported item (diff)
downloadapache2-16c5c09faba96fc09f6295bb42a3cb8f6a10c7fc.tar.xz
apache2-16c5c09faba96fc09f6295bb42a3cb8f6a10c7fc.zip
elaborate a bit about what ivm does, and add an example script
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1470271 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'docs/manual/mod/mod_lua.xml')
-rw-r--r--docs/manual/mod/mod_lua.xml14
1 files changed, 13 insertions, 1 deletions
diff --git a/docs/manual/mod/mod_lua.xml b/docs/manual/mod/mod_lua.xml
index 32bb521950..118815e67c 100644
--- a/docs/manual/mod/mod_lua.xml
+++ b/docs/manual/mod/mod_lua.xml
@@ -891,10 +891,22 @@ r:dbacquire(dbType[, dbParams]) -- Acquires a connection to a database and retur
r:ivm_set("key", value) -- Set an Inter-VM variable to hold a specific value.
-- These values persist even though the VM is gone or not being used,
-- and so should only be used if MaxConnectionsPerChild is > 0
- -- Values can be numbers, strings and booleans.
+ -- Values can be numbers, strings and booleans, and are stored on a
+ -- per process basis (so they won't do much good with a prefork mpm)
r:ivm_get("key") -- Fetches a variable set by ivm_set. Returns the contents of the variable
-- if it exists or nil if no such variable exists.
+
+-- An example getter/setter that saves a global variable outside the VM:
+function handle(r)
+ -- First VM to call this will get no value, and will have to create it
+ local foo = r:ivm_get("cached_data")
+ if not foo then
+ foo = do_some_calcs() -- fake some return value
+ r:ivm_set("cached_data", foo) -- set it globally
+ end
+ r:puts("Cached data is: ", foo)
+end
</highlight>
</section>