1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dekalee\AdbackAnalytics\Driver; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class RedisScriptCache |
7
|
|
|
*/ |
8
|
|
|
class RedisScriptCache implements ScriptCacheInterface |
9
|
|
|
{ |
10
|
|
|
protected $redis; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @param \Redis $redis |
14
|
|
|
*/ |
15
|
|
|
public function __construct(\Redis $redis) |
16
|
|
|
{ |
17
|
|
|
$this->redis = $redis; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @return bool |
22
|
|
|
*/ |
23
|
|
|
public function isAnalyticsConfigured() |
24
|
|
|
{ |
25
|
|
|
return $this->redis->exists('adback_analytics_url'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param string $domain |
30
|
|
|
*/ |
31
|
|
|
public function setAnalyticsUrl($domain) |
32
|
|
|
{ |
33
|
|
|
$this->redis->set('adback_analytics_url', $domain); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return string |
38
|
|
|
*/ |
39
|
|
|
public function getAnalyticsUrl() |
40
|
|
|
{ |
41
|
|
|
return $this->redis->get('adback_analytics_url'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param string $script |
46
|
|
|
*/ |
47
|
|
|
public function setAnalyticsScript($script) |
48
|
|
|
{ |
49
|
|
|
$this->redis->set('adback_analytics_script', $script); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
|
|
public function getAnalyticsScript() |
56
|
|
|
{ |
57
|
|
|
return $this->redis->get('adback_analytics_script'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return bool |
62
|
|
|
*/ |
63
|
|
|
public function isMessageConfigured() |
64
|
|
|
{ |
65
|
|
|
return $this->redis->exists('adback_message_url'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return bool |
70
|
|
|
*/ |
71
|
|
|
public function isAutopromoBannerConfigured() |
72
|
|
|
{ |
73
|
|
|
return $this->redis->exists('adback_autopromo_banner_url'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $domain |
78
|
|
|
*/ |
79
|
|
|
public function setMessageUrl($domain) |
80
|
|
|
{ |
81
|
|
|
$this->redis->set('adback_message_url', $domain); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getMessageUrl() |
88
|
|
|
{ |
89
|
|
|
return $this->redis->get('adback_message_url'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string $script |
94
|
|
|
*/ |
95
|
|
|
public function setMessageScript($script) |
96
|
|
|
{ |
97
|
|
|
$this->redis->set('adback_message_script', $script); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return string |
102
|
|
|
*/ |
103
|
|
|
public function getMessageScript() |
104
|
|
|
{ |
105
|
|
|
return $this->redis->get('adback_message_script'); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param string $domain |
110
|
|
|
*/ |
111
|
|
|
public function setAutopromoBannerUrl($domain) |
112
|
|
|
{ |
113
|
|
|
$this->redis->set('adback_autopromo_banner_url', $domain); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return string |
118
|
|
|
*/ |
119
|
|
|
public function getAutopromoBannerUrl() |
120
|
|
|
{ |
121
|
|
|
return $this->redis->get('adback_autopromo_banner_url'); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param string $script |
126
|
|
|
*/ |
127
|
|
|
public function setAutopromoBannerScript($script) |
128
|
|
|
{ |
129
|
|
|
$this->redis->set('adback_autopromo_banner_script', $script); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return string |
134
|
|
|
*/ |
135
|
|
|
public function getAutopromoBannerScript() |
136
|
|
|
{ |
137
|
|
|
return $this->redis->get('adback_autopromo_banner_script'); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Clear analytics data |
142
|
|
|
*/ |
143
|
|
|
public function clearAnalyticsData() |
144
|
|
|
{ |
145
|
|
|
$this->redis->del('adback_analytics_url', 'adback_analytics_script'); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Clear message data |
150
|
|
|
*/ |
151
|
|
|
public function clearMessageData() |
152
|
|
|
{ |
153
|
|
|
$this->redis->del('adback_message_url', 'adback_message_script'); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Clear autopromo banner data |
158
|
|
|
*/ |
159
|
|
|
public function clearAutopromoBannerData() |
160
|
|
|
{ |
161
|
|
|
$this->redis->del('adback_autopromo_banner_url', 'adback_autopromo_banner_script'); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
} |
165
|
|
|
|