You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by hu...@apache.org on 2013/04/21 09:12:28 UTC

svn commit: r1470271 - /httpd/httpd/trunk/docs/manual/mod/mod_lua.xml

Author: humbedooh
Date: Sun Apr 21 07:12:27 2013
New Revision: 1470271

URL: http://svn.apache.org/r1470271
Log:
elaborate a bit about what ivm does, and add an example script

Modified:
    httpd/httpd/trunk/docs/manual/mod/mod_lua.xml

Modified: httpd/httpd/trunk/docs/manual/mod/mod_lua.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_lua.xml?rev=1470271&r1=1470270&r2=1470271&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_lua.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_lua.xml Sun Apr 21 07:12:27 2013
@@ -891,10 +891,22 @@ r:dbacquire(dbType[, dbParams]) -- Acqui
 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>