msys.counter.inc
Last updated March 2020
Name
msys.counter.inc — Increment a counter
Synopsis
msys.counter.inc(object_or_path);
Description
The first argument is either a path to a counter (for example, /sites/sit_name/errors
) or a counter object that was returned by msys.counter.open
. If a string is provided containing the path to a counter that does not exist, the counter is created with STRICT semantics. The counter value is atomically incremented. For performance reasons, use of counter handles is recommended. Find an example below.
require("msys.core");
require("msys.counter");
local mod = {};
local msys_emails = msys.counter.open("/sites/examples/messagesystems_correspondence");
function mod:validate_mailfrom(str, accept, vctx)
str = tostring(str);
if (string.find(str, "@messagesystems.com") != nil) then
msys.counter.inc(msys_emails);
end
return msys.core.VALIDATE_CONT;
end
msys.registerModule("counter", mod);
require("msys.core"); require("msys.counter"); local mod = {}; function mod:validate_mailfrom(str, accept, vctx) str = tostring(str); if (string.find(str, "@messagesystems.com") != nil) then msys.counter.inc("/sites/site_name/messagesystems_correspondence"); end return msys.core.VALIDATE_CONT; end msys.registerModule("counter", mod);
Enable this function with the statement require('msys.counter');
.
See Also
Was this page helpful?