SAE Cloud Application Counter tool for access counting
First, Introduction
Sina SAE has provided us with a fast-growing cloud application platform, some of which are very interesting to use.
Like the counter tool, we can use it to implement an access counter.
We can find it here.
The page displays the tool's constructors and invocation examples.
classsaecounter {__construct ();//constructor that throws an exception if it fails. BOOL Create (string name, [int initial_value =0]);//Add a counter name with a default value of 0. The success returns True, and the failure returns false. BOOL Remove (string name);//Remove the counter named name. The success returns True, and the failure returns false. BOOL Exists (string name);//Determine if the counter name exists. There is a return of true, there is no return false. MixedList();//Gets all the counters for the app. The array returned successfully, and the failure returned false. Mixed length ();//successfully returned the total number of counters for the app, and failed to return false. Mixed get (string name);//Gets the value of the counter name. The value of the counter is returned successfully, and the failure returns false. BOOL Set (string name, int value);//Reset the counter name to value. The success returns True, and the failure returns false. Mixed Mget (Array(name1,name2,...));//Get multiple counter values simultaneously. The hash array was successfully returned with the counter named Index, and the failure returned false. Mixed GetAll ();//Gets the value of all counters for the app. Returns the same mget operation. Mixed incr (string name, [int vaule =1]);//To the counter name to do the addition operation, the default plus 1. The value of the counter is returned successfully, and the failure returns false. Mixed DECR (string name, [int vaule =1]);//subtraction of counter name, minus 1 by default. The value of the counter is returned successfully, and the failure returns false. }?>
Invoke Example
try{ $c = new SaeCounter(); }catch(Exception$ex){ die($ex->getMessage()); } $c->get('c1'); // 返回c1的值$c->set('c1', 100); // 返回true$c->incr('c1'); // 返回101$c->decr('c1'); // 返回100?>
Create a process
Start by creating a new counter, where you create a new counter variable.
Here we set a Request_counter variable, the initial value is initially set to 0.
Add the counter code to the portal file as follows:
//---------------添加计数器功能----------------add-time-15/09/06-pm--------try{ $cnew SaeCounter(); } catch(Exception$ex){ die($ex->getMessage()); } $c->get('request_counter'); // 获取值$c->incr('request_counter'// 计数器加1//--------------计数功能添加结束---------------------------------------------
This way we can visually see the latest access data, and of course we can combine our access log files to make it more perfect.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the SAE Cloud Application Counter tool to achieve the access count, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.