Counter
Purpose¶
Access and control of the Counters service behaviour.
Methods¶
Binding name: p6.counter
list¶
Returns a list of all counter names as a JSON text.
Syntax
String p6.counter.list()
Example
import groovy.json.JsonSlurper
def counters = new JsonSlurper().parseText(p6.counter.list())
counters.each { c ->
println "AppKey: " + c['appKey']
println "Name: " + c['name']
println "Value: " + c['value']
}
get¶
Returns the counter detail as a JSON text
Syntax
String p6.counter.get(String counterName)
Tip
You could omit the prefix <appKey>.
if the counter is not packaged.
Examples
Unpackaged
import groovy.json.JsonSlurper
def c = new JsonSlurper().parseText(p6.counter.get('counterId'))
println "Value: " + c['value']
Packaged
import groovy.json.JsonSlurper
def c = new JsonSlurper().parseText(p6.counter.get('myApp.counterId'))
println "Value: " + c['value']
synchronize¶
Returns the synchronized counter value
Syntax
String p6.counter.synchronize(String counterName)
Tip
You could omit the prefix <appKey>.
if the counter is not packaged.
Examples
Unpackaged
def syncValue = p6.counter.synchronize('counterName')
println "Value: " + syncValue
Packaged
def syncValue = p6.counter.synchronize('myApp.counterName')
println "Value: " + syncValue