1 个管道
的构建
通过
耗费
7 秒
后台修改会员,充值接口
正在显示
55 个修改的文件
包含
237 行增加
和
4268 行删除
此 diff 太大无法显示。
application/api/controller/Ems.php
已删除
100644 → 0
1 | -<?php | ||
2 | - | ||
3 | -namespace app\api\controller; | ||
4 | - | ||
5 | -use app\common\controller\Api; | ||
6 | -use app\common\library\Ems as Emslib; | ||
7 | -use app\common\model\User; | ||
8 | - | ||
9 | -/** | ||
10 | - * 邮箱验证码接口 | ||
11 | - */ | ||
12 | -class Ems extends Api | ||
13 | -{ | ||
14 | - protected $noNeedLogin = '*'; | ||
15 | - protected $noNeedRight = '*'; | ||
16 | - | ||
17 | - public function _initialize() | ||
18 | - { | ||
19 | - parent::_initialize(); | ||
20 | - \think\Hook::add('ems_send', function ($params) { | ||
21 | - $obj = \app\common\library\Email::instance(); | ||
22 | - $result = $obj | ||
23 | - ->to($params->email) | ||
24 | - ->subject('验证码') | ||
25 | - ->message("你的验证码是:" . $params->code) | ||
26 | - ->send(); | ||
27 | - return $result; | ||
28 | - }); | ||
29 | - } | ||
30 | - | ||
31 | - /** | ||
32 | - * 发送验证码 | ||
33 | - * | ||
34 | - * @param string $email 邮箱 | ||
35 | - * @param string $event 事件名称 | ||
36 | - */ | ||
37 | - public function send() | ||
38 | - { | ||
39 | - $email = $this->request->request("email"); | ||
40 | - $event = $this->request->request("event"); | ||
41 | - $event = $event ? $event : 'register'; | ||
42 | - | ||
43 | - $last = Emslib::get($email, $event); | ||
44 | - if ($last && time() - $last['createtime'] < 60) { | ||
45 | - $this->error(__('发送频繁')); | ||
46 | - } | ||
47 | - if ($event) { | ||
48 | - $userinfo = User::getByEmail($email); | ||
49 | - if ($event == 'register' && $userinfo) { | ||
50 | - //已被注册 | ||
51 | - $this->error(__('已被注册')); | ||
52 | - } elseif (in_array($event, ['changeemail']) && $userinfo) { | ||
53 | - //被占用 | ||
54 | - $this->error(__('已被占用')); | ||
55 | - } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) { | ||
56 | - //未注册 | ||
57 | - $this->error(__('未注册')); | ||
58 | - } | ||
59 | - } | ||
60 | - $ret = Emslib::send($email, null, $event); | ||
61 | - if ($ret) { | ||
62 | - $this->success(__('发送成功')); | ||
63 | - } else { | ||
64 | - $this->error(__('发送失败')); | ||
65 | - } | ||
66 | - } | ||
67 | - | ||
68 | - /** | ||
69 | - * 检测验证码 | ||
70 | - * | ||
71 | - * @param string $email 邮箱 | ||
72 | - * @param string $event 事件名称 | ||
73 | - * @param string $captcha 验证码 | ||
74 | - */ | ||
75 | - public function check() | ||
76 | - { | ||
77 | - $email = $this->request->request("email"); | ||
78 | - $event = $this->request->request("event"); | ||
79 | - $event = $event ? $event : 'register'; | ||
80 | - $captcha = $this->request->request("captcha"); | ||
81 | - | ||
82 | - if ($event) { | ||
83 | - $userinfo = User::getByEmail($email); | ||
84 | - if ($event == 'register' && $userinfo) { | ||
85 | - //已被注册 | ||
86 | - $this->error(__('已被注册')); | ||
87 | - } elseif (in_array($event, ['changeemail']) && $userinfo) { | ||
88 | - //被占用 | ||
89 | - $this->error(__('已被占用')); | ||
90 | - } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) { | ||
91 | - //未注册 | ||
92 | - $this->error(__('未注册')); | ||
93 | - } | ||
94 | - } | ||
95 | - $ret = Emslib::check($email, $captcha, $event); | ||
96 | - if ($ret) { | ||
97 | - $this->success(__('成功')); | ||
98 | - } else { | ||
99 | - $this->error(__('验证码不正确')); | ||
100 | - } | ||
101 | - } | ||
102 | -} |
@@ -2,8 +2,6 @@ | @@ -2,8 +2,6 @@ | ||
2 | 2 | ||
3 | namespace app\api\controller; | 3 | namespace app\api\controller; |
4 | 4 | ||
5 | -use app\admin\model\PayMember; | ||
6 | -use app\admin\model\ToBalance; | ||
7 | use app\common\controller\Api; | 5 | use app\common\controller\Api; |
8 | use EasyWeChat\Factory; | 6 | use EasyWeChat\Factory; |
9 | use function GuzzleHttp\Promise\inspect; | 7 | use function GuzzleHttp\Promise\inspect; |
@@ -19,7 +17,6 @@ use function EasyWeChat\Kernel\Support\generate_sign; | @@ -19,7 +17,6 @@ use function EasyWeChat\Kernel\Support\generate_sign; | ||
19 | */ | 17 | */ |
20 | class Pay extends Api | 18 | class Pay extends Api |
21 | { | 19 | { |
22 | - protected $noNeedLogin = ['payMemberNotify','paySecurityNotify','payOrderNotify']; | ||
23 | protected $noNeedRight = ['*']; | 20 | protected $noNeedRight = ['*']; |
24 | protected $uid = '';//token存贮uid | 21 | protected $uid = '';//token存贮uid |
25 | protected $order_status = [];//订单状态 | 22 | protected $order_status = [];//订单状态 |
@@ -30,226 +27,117 @@ class Pay extends Api | @@ -30,226 +27,117 @@ class Pay extends Api | ||
30 | } | 27 | } |
31 | 28 | ||
32 | /** | 29 | /** |
33 | - * @ApiTitle (充值/支付订单) | 30 | + * @ApiTitle (充值支付) |
34 | * @ApiSummary (充值支付) | 31 | * @ApiSummary (充值支付) |
35 | * @ApiMethod (POST) | 32 | * @ApiMethod (POST) |
36 | * @ApiRoute (/api/pay/pay) | 33 | * @ApiRoute (/api/pay/pay) |
37 | * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | 34 | * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") |
38 | * | 35 | * |
39 | - * @ApiParams (name="openid", type="string", required=true, description="小程序openid") | ||
40 | - * @ApiParams (name="num", type="inter", required=false, description="支付订单号") | 36 | + * @ApiParams (name="order_id", type="inter", required=true, description="订单id") |
41 | * | 37 | * |
42 | */ | 38 | */ |
43 | public function pay(){ | 39 | public function pay(){ |
40 | + $rule = config('verify.path'); | ||
44 | if($this->request->isPost()){ | 41 | if($this->request->isPost()){ |
45 | - $openid = $this->request->post('openid'); | ||
46 | - $order_sn = $this->request->post('num'); | ||
47 | - | 42 | + $order_id = $this->request->post('order_id'); |
43 | + $openid = $this->getopenid(); | ||
48 | if(empty($openid)){ | 44 | if(empty($openid)){ |
49 | $this->error(['code'=>2,'msg'=>'openid不能为空']); | 45 | $this->error(['code'=>2,'msg'=>'openid不能为空']); |
50 | } | 46 | } |
51 | - if($order_sn){ | ||
52 | - //支付订单 | ||
53 | - $res = Db::name('order')->where(['num'=>$order_sn,'uid'=>$this->uid])->find(); | ||
54 | - if($res){ | ||
55 | - if($res['status'] == 2){ | ||
56 | - $this->error('该订单已支付过了'); | ||
57 | - }else{ | ||
58 | - //创建支付对象 | ||
59 | - $config = config('verify.wx_pay'); | ||
60 | - $app = Factory::payment($config); | ||
61 | - $result = $app->order->unify([ | ||
62 | - 'body' => '山东航拍', | ||
63 | - 'out_trade_no' => $order_sn,//支付订单号 | ||
64 | - 'total_fee' => $money*100,//单位分 | ||
65 | - 'notify_url' => $notify_url, // 支付结果通知网址,如果不设置则会使用配置里的默认地址 | ||
66 | - 'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型 | ||
67 | - 'openid' => $openid, | ||
68 | - ]); | ||
69 | - if($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS'){ | ||
70 | - $params = [ | ||
71 | - 'appId' => $config['app_id'], | ||
72 | - 'timeStamp' => time(), | ||
73 | - 'nonceStr' => $result['nonce_str'], // 统一下单返回的随机字符串 | ||
74 | - 'package' => 'prepay_id='.$result['prepay_id'], // 统一下单Id | ||
75 | - 'signType' => 'MD5', // 签名方法 | ||
76 | - ]; | ||
77 | - // 注意这里用的是商户平台的Key进行二次签名 | ||
78 | - $params['paySign'] = generate_sign($params, $config['key']); | ||
79 | - $this->success('成功',$params); | ||
80 | - } | ||
81 | - $this->error($result['err_code_des']); | ||
82 | - } | 47 | + $data = Db::name('toporder')->where('id',$order_id)->find(); |
48 | + if($data){ | ||
49 | + if($data['status'] == 2){ | ||
50 | + $this->error('该订单已支付过了'); | ||
83 | }else{ | 51 | }else{ |
84 | - $this->error('无效的订单'); | 52 | + //创建支付对象 |
53 | + $config = config('verify.wx_pay'); | ||
54 | + $app = Factory::payment($config); | ||
55 | + $result = $app->order->unify([ | ||
56 | + 'body' => '山东航拍', | ||
57 | + 'out_trade_no' => $data['num'],//支付订单号 | ||
58 | + 'total_fee' => $data['money']*100,//单位分 | ||
59 | + 'notify_url' => $rule.'api/pay/payOrderNotify', // 支付结果通知网址,如果不设置则会使用配置里的默认地址 | ||
60 | + 'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型 | ||
61 | + 'openid' => $openid, | ||
62 | + ]); | ||
63 | + if($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS'){ | ||
64 | + $params = [ | ||
65 | + 'appId' => $config['app_id'], | ||
66 | + 'timeStamp' => time(), | ||
67 | + 'nonceStr' => $result['nonce_str'], // 统一下单返回的随机字符串 | ||
68 | + 'package' => 'prepay_id='.$result['prepay_id'], // 统一下单Id | ||
69 | + 'signType' => 'MD5', // 签名方法 | ||
70 | + ]; | ||
71 | + // 注意这里用的是商户平台的Key进行二次签名 | ||
72 | + $params['paySign'] = generate_sign($params, $config['key']); | ||
73 | + $this->success('成功',$params); | ||
74 | + } | ||
75 | + $this->error($result['err_code_des']); | ||
85 | } | 76 | } |
77 | + }else{ | ||
78 | + $this->error('无效的订单'); | ||
86 | } | 79 | } |
87 | }else{ | 80 | }else{ |
88 | $this->error('请求方式错误'); | 81 | $this->error('请求方式错误'); |
89 | } | 82 | } |
90 | } | 83 | } |
91 | 84 | ||
92 | - //购买会员回调通知(无需调用) | ||
93 | - public function payMemberNotify(){ | ||
94 | - $config = config('verify.wx_pay'); | ||
95 | - $app = Factory::payment($config); | ||
96 | - Log::info('会员'); | ||
97 | - $response = $app->handlePaidNotify(function($message, $fail){ | ||
98 | - //return_code 表示通信状态 | ||
99 | - Log::info($message); | ||
100 | - if ($message['return_code'] === 'SUCCESS') { | 85 | + //获取用户openid |
86 | + public function getopenid() | ||
87 | + { | ||
88 | + $user_id = $this->uid; | ||
89 | + $openid = Db::name('user') | ||
90 | + ->where('id',$user_id) | ||
91 | + ->field('openid') | ||
92 | + ->find(); | ||
101 | 93 | ||
102 | - if ($message['result_code'] === 'SUCCESS') { | ||
103 | - //支付成功 | ||
104 | - //更新成为会员 | ||
105 | - $userModel = new User(); | ||
106 | - $userModel->where('openid',$message['openid'])->update(['member'=>1]); | ||
107 | - //增加记录 | ||
108 | - $payMemberModel = new PayMember(); | ||
109 | - $payMemberModel->create(['openid'=>$message['openid'],'pay_order'=>$message['out_trade_no']]); | ||
110 | - }elseif($message['result_code'] === 'FAIL') { | ||
111 | - //支付失败 | ||
112 | - } | ||
113 | - } else { | ||
114 | - return $fail('通信失败,请稍后再通知我'); | ||
115 | - } | ||
116 | - return true; // 返回处理完成 | ||
117 | - }); | ||
118 | - $response->send(); | 94 | + return $openid; |
119 | } | 95 | } |
120 | 96 | ||
121 | - //支付订单(无需调用) | 97 | + //支付订单结果通知(无需调用) |
122 | public function payOrderNotify(){ | 98 | public function payOrderNotify(){ |
123 | $config = config('verify.wx_pay'); | 99 | $config = config('verify.wx_pay'); |
124 | $app = Factory::payment($config); | 100 | $app = Factory::payment($config); |
125 | $response = $app->handlePaidNotify(function($message, $fail){ | 101 | $response = $app->handlePaidNotify(function($message, $fail){ |
102 | + $data = Db::name('toporder') | ||
103 | + ->where('num',$message['out_trade_no']) | ||
104 | + ->find(); | ||
126 | //return_code 表示通信状态 | 105 | //return_code 表示通信状态 |
127 | if ($message['return_code'] === 'SUCCESS') { | 106 | if ($message['return_code'] === 'SUCCESS') { |
128 | 107 | ||
129 | if ($message['result_code'] === 'SUCCESS') { | 108 | if ($message['result_code'] === 'SUCCESS') { |
130 | //支付成功,更新订单状态 | 109 | //支付成功,更新订单状态 |
131 | - $orderModel = new \app\admin\model\Order(); | ||
132 | - $orderModel->where(['order_sn'=>$message['out_trade_no']])->update(['status'=>1]); | ||
133 | - | ||
134 | - //创建订房记录 | ||
135 | - $this->auth->createHouseRecord($message['out_trade_no']); | ||
136 | - | ||
137 | - }elseif($message['result_code'] === 'FAIL') { | 110 | + $toporder['status'] = 2; |
111 | + $toporder['paytime'] = time(); | ||
112 | + $money = $data['money']; | ||
113 | + // 启动事务 | ||
114 | + Db::startTrans(); | ||
115 | + try{ | ||
116 | + $res = Db::name('toporder')->where('num',$message['out_trade_no'])->update($toporder); | ||
117 | + $arr = Db::name('user')->where('id',$data['user_id'])->find(); | ||
118 | + $list['money'] = $arr['money'] + $money; | ||
119 | + $info = Db::name('user')->where('id',$data['user_id'])->update(['money'=>$list['money']]); | ||
120 | + if($res && $info){ | ||
121 | + true; | ||
122 | + }else{ | ||
123 | + $this->error(['code'=>2,'msg'=>'充值失败']); | ||
124 | + } | ||
125 | + // 提交事务 | ||
126 | + Db::commit(); | ||
127 | + } catch (\Exception $e) { | ||
128 | + dump($e->getMessage()); | ||
129 | + // 回滚事务 | ||
130 | + Db::rollback(); | ||
131 | + } | ||
132 | + }else{ | ||
138 | //支付失败 | 133 | //支付失败 |
134 | + Db::name('toporder')->where('num',$message['out_trade_no'])->update(['status'=>1]); | ||
139 | } | 135 | } |
140 | - } else { | 136 | + }else{ |
141 | return $fail('通信失败,请稍后再通知我'); | 137 | return $fail('通信失败,请稍后再通知我'); |
142 | } | 138 | } |
143 | return true; // 返回处理完成 | 139 | return true; // 返回处理完成 |
144 | }); | 140 | }); |
145 | $response->send(); | 141 | $response->send(); |
146 | } | 142 | } |
147 | - | ||
148 | - | ||
149 | - /** | ||
150 | - * @ApiTitle (更新订单号(支付订单失败后调用)) | ||
151 | - * @ApiSummary (更新订单号(支付订单失败后调用)) | ||
152 | - * @ApiMethod (POST) | ||
153 | - * @ApiRoute (/api/pay/updateOrder) | ||
154 | - * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
155 | - * | ||
156 | - * @ApiParams (name="order_sn", type="inter", required=false, description="支付订单号") | ||
157 | - * | ||
158 | - * @ApiReturn({ | ||
159 | - "code": 1, | ||
160 | - "msg": "成功", | ||
161 | - "time": "1571812329", | ||
162 | - "data": null | ||
163 | - }) | ||
164 | - */ | ||
165 | - public function updateOrder(){ | ||
166 | - if($this->request->isPost()){ | ||
167 | - $order_sn = $this->request->post('order_sn'); | ||
168 | - | ||
169 | - $rule = config('verify.order_sn'); | ||
170 | - $validate = new Validate($rule['rule'],$rule['msg']); | ||
171 | - if (!$validate->check(['order_sn'=>$order_sn])) { | ||
172 | - $this->error($validate->getError()); | ||
173 | - } | ||
174 | - | ||
175 | - $orderModel = new \app\admin\model\Order(); | ||
176 | - $pay_order = $this->auth->genPayOrderSn('pay');//支付订单号 | ||
177 | - $res = $orderModel->where(['order_sn'=>$order_sn,'uid'=>$this->uid])->update(['order_sn'=>$pay_order]); | ||
178 | - if($res){ | ||
179 | - $this->success('成功'); | ||
180 | - }else{ | ||
181 | - $this->error('失败'); | ||
182 | - } | ||
183 | - }else{ | ||
184 | - $this->error('请求方式错误'); | ||
185 | - } | ||
186 | - } | ||
187 | - | ||
188 | - /** | ||
189 | - * @ApiTitle (提现到微信零钱) | ||
190 | - * @ApiSummary (提现到微信零钱) | ||
191 | - * @ApiMethod (POST) | ||
192 | - * @ApiRoute (/api/pay/payBalance) | ||
193 | - * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
194 | - * | ||
195 | - * @ApiParams (name="openid", type="string", required=true, description="小程序openid") | ||
196 | - * @ApiParams (name="price", type="inter", required=true, description="提现金额") | ||
197 | - */ | ||
198 | - public function payBalance(){ | ||
199 | - if($this->request->isPost()){ | ||
200 | - $price = $this->request->post('price'); | ||
201 | - $openid = $this->request->post('openid'); | ||
202 | - | ||
203 | - $rule = config('verify.to_balance'); | ||
204 | - $validate = new Validate($rule['rule'],$rule['msg']); | ||
205 | - if (!$validate->check(['price'=>$price,'openid'=>$openid])) { | ||
206 | - $this->error($validate->getError()); | ||
207 | - } | ||
208 | - | ||
209 | - if($price < 0.3){ | ||
210 | - $this->error('提现金额不能低于0.3元'); | ||
211 | - } | ||
212 | - | ||
213 | - //每天提现次数不超过三次 | ||
214 | - $count = Db::name('to_balance')->where('uid',$this->uid)->whereTime('createtime','today')->count(); | ||
215 | - if($count >= 3){ | ||
216 | - $this->error('每天提现次数不能超过3次'); | ||
217 | - } | ||
218 | - //查询该用户钱包金额 | ||
219 | - $userModel = new User(); | ||
220 | - $user = $userModel->where(['id'=>$this->uid])->field('id,money,nickname')->find(); | ||
221 | - if($price > $user['money']){ | ||
222 | - $this->error('钱包金额不足'); | ||
223 | - } | ||
224 | - | ||
225 | - //创建支付对象 | ||
226 | - $config = config('verify.wx_pay'); | ||
227 | - $app = Factory::payment($config); | ||
228 | - $balance_order = $this->auth->genPayOrderSn('balance');//提现单号 | ||
229 | - $result = $app->transfer->toBalance([ | ||
230 | - 'partner_trade_no' => $balance_order, // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号) | ||
231 | - 'openid' => $openid, | ||
232 | - 'check_name' => 'NO_CHECK', // NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名 | ||
233 | - 're_user_name' => '', // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名 | ||
234 | - 'amount' => $price*100, // 企业付款金额,单位为分 | ||
235 | - 'desc' => '提现到零钱', // 企业付款操作说明信息。必填 | ||
236 | - ]); | ||
237 | - if($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS'){ | ||
238 | - //创建提现记录 | ||
239 | - $balanceRecordModel = new ToBalance(); | ||
240 | - $data['uid'] = $this->uid; | ||
241 | - $data['openid'] = $openid; | ||
242 | - $data['price'] = $price; | ||
243 | - $data['to_order'] = $result['partner_trade_no']; | ||
244 | - $balanceRecordModel->create($data); | ||
245 | - //更新余额表 | ||
246 | - $userModel = new User(); | ||
247 | - $userModel->where(['id'=>$this->uid])->setDec('money',$price); | ||
248 | - $this->success('成功'); | ||
249 | - } | ||
250 | - $this->error($result['err_code_des']); | ||
251 | - }else{ | ||
252 | - $this->error('请求方式错误'); | ||
253 | - } | ||
254 | - } | ||
255 | } | 143 | } |
@@ -563,47 +563,4 @@ class User extends Api | @@ -563,47 +563,4 @@ class User extends Api | ||
563 | 563 | ||
564 | } | 564 | } |
565 | 565 | ||
566 | - /** | ||
567 | - * @ApiTitle (充值支付) | ||
568 | - * @ApiSummary (充值支付) | ||
569 | - * @ApiMethod (POST) | ||
570 | - * @ApiRoute (/api/user/pay) | ||
571 | - * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
572 | - * | ||
573 | - * @ApiParams (name="order_id", type="inter", required=true, description="订单id") | ||
574 | - * | ||
575 | - * @ApiReturn({ | ||
576 | - "code": 1, | ||
577 | - "msg": "成功", | ||
578 | - "time": "1571492001", | ||
579 | - }) | ||
580 | - */ | ||
581 | - public function pay() | ||
582 | - { | ||
583 | - $user_id = $this->uid; | ||
584 | - $id = $this->request->post('order_id'); | ||
585 | - if(empty($id)){ | ||
586 | - $this->error(['code'=>2,'msg'=>'确实必要参数']); | ||
587 | - } | ||
588 | - $where['id'] = ['eq',$id]; | ||
589 | - $where['user_id'] = ['eq',$user_id]; | ||
590 | - $data = Db::name('toporder')->where($where)->find(); | ||
591 | - if(empty($data)){ | ||
592 | - $this->error(['code'=>41001,'msg'=>'数据错误']); | ||
593 | - } | ||
594 | - $openid = $this->getopenid(); | ||
595 | - $this->success('SUCCESS'); | ||
596 | - } | ||
597 | - | ||
598 | - public function getopenid() | ||
599 | - { | ||
600 | - $user_id = $this->uid; | ||
601 | - $openid = Db::name('user') | ||
602 | - ->where('id',$user_id) | ||
603 | - ->field('openid') | ||
604 | - ->find(); | ||
605 | - | ||
606 | - return $openid; | ||
607 | - } | ||
608 | - | ||
609 | } | 566 | } |
@@ -17,14 +17,14 @@ | @@ -17,14 +17,14 @@ | ||
17 | "require": { | 17 | "require": { |
18 | "php": ">=5.6.0", | 18 | "php": ">=5.6.0", |
19 | "topthink/framework": "~5.0.24", | 19 | "topthink/framework": "~5.0.24", |
20 | - "overtrue/wechat": "~3.1", | ||
21 | "endroid/qr-code": "^1.9", | 20 | "endroid/qr-code": "^1.9", |
22 | "topthink/think-captcha": "^1.0", | 21 | "topthink/think-captcha": "^1.0", |
23 | "mtdowling/cron-expression": "^1.2", | 22 | "mtdowling/cron-expression": "^1.2", |
24 | "phpmailer/phpmailer": "^5.2", | 23 | "phpmailer/phpmailer": "^5.2", |
25 | "karsonzhang/fastadmin-addons": "~1.1.9", | 24 | "karsonzhang/fastadmin-addons": "~1.1.9", |
26 | "overtrue/pinyin": "~3.0", | 25 | "overtrue/pinyin": "~3.0", |
27 | - "phpoffice/phpspreadsheet": "^1.2" | 26 | + "phpoffice/phpspreadsheet": "^1.2", |
27 | + "overtrue/wechat": "~4.0" | ||
28 | }, | 28 | }, |
29 | "config": { | 29 | "config": { |
30 | "preferred-install": "dist" | 30 | "preferred-install": "dist" |
此 diff 太大无法显示。
@@ -25,15 +25,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -25,15 +25,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
25 | [ | 25 | [ |
26 | {checkbox: true}, | 26 | {checkbox: true}, |
27 | {field: 'id', title: __('Id'), sortable: true}, | 27 | {field: 'id', title: __('Id'), sortable: true}, |
28 | - {field: 'group.name', title: __('Group')}, | ||
29 | - {field: 'username', title: __('Username'), operate: 'LIKE'}, | 28 | + // {field: 'group.name', title: __('Group')}, |
29 | + // {field: 'username', title: __('Username'), operate: 'LIKE'}, | ||
30 | {field: 'nickname', title: __('Nickname'), operate: 'LIKE'}, | 30 | {field: 'nickname', title: __('Nickname'), operate: 'LIKE'}, |
31 | - {field: 'email', title: __('Email'), operate: 'LIKE'}, | ||
32 | - {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, | 31 | + // {field: 'email', title: __('Email'), operate: 'LIKE'}, |
32 | + // {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, | ||
33 | {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false}, | 33 | {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false}, |
34 | - {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true}, | 34 | + // {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true}, |
35 | {field: 'gender', title: __('Gender'), visible: false, searchList: {1: __('Male'), 0: __('Female')}}, | 35 | {field: 'gender', title: __('Gender'), visible: false, searchList: {1: __('Male'), 0: __('Female')}}, |
36 | - {field: 'score', title: __('Score'), operate: 'BETWEEN', sortable: true}, | 36 | + // {field: 'score', title: __('Score'), operate: 'BETWEEN', sortable: true}, |
37 | {field: 'successions', title: __('Successions'), visible: false, operate: 'BETWEEN', sortable: true}, | 37 | {field: 'successions', title: __('Successions'), visible: false, operate: 'BETWEEN', sortable: true}, |
38 | {field: 'maxsuccessions', title: __('Maxsuccessions'), visible: false, operate: 'BETWEEN', sortable: true}, | 38 | {field: 'maxsuccessions', title: __('Maxsuccessions'), visible: false, operate: 'BETWEEN', sortable: true}, |
39 | {field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | 39 | {field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, |
@@ -41,7 +41,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -41,7 +41,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
41 | {field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | 41 | {field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, |
42 | {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search}, | 42 | {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search}, |
43 | {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}}, | 43 | {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}}, |
44 | - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 44 | + {field: 'money', title: __('账号余额')}, |
45 | + {field: 'is_vip', title: __('是否为会员'),formatter: Table.api.formatter.label,searchList:{'0': '否', '1': '是'}}, | ||
46 | + // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | ||
45 | ] | 47 | ] |
46 | ] | 48 | ] |
47 | }); | 49 | }); |
@@ -2,6 +2,6 @@ | @@ -2,6 +2,6 @@ | ||
2 | 2 | ||
3 | // autoload.php @generated by Composer | 3 | // autoload.php @generated by Composer |
4 | 4 | ||
5 | -require_once __DIR__ . '/composer' . '/autoload_real.php'; | 5 | +require_once __DIR__ . '/composer/autoload_real.php'; |
6 | 6 | ||
7 | return ComposerAutoloaderInit2537a12e3b63e265e25ee9e73315e195::getLoader(); | 7 | return ComposerAutoloaderInit2537a12e3b63e265e25ee9e73315e195::getLoader(); |
@@ -55,6 +55,7 @@ class ClassLoader | @@ -55,6 +55,7 @@ class ClassLoader | ||
55 | private $classMap = array(); | 55 | private $classMap = array(); |
56 | private $classMapAuthoritative = false; | 56 | private $classMapAuthoritative = false; |
57 | private $missingClasses = array(); | 57 | private $missingClasses = array(); |
58 | + private $apcuPrefix; | ||
58 | 59 | ||
59 | public function getPrefixes() | 60 | public function getPrefixes() |
60 | { | 61 | { |
@@ -272,6 +273,26 @@ class ClassLoader | @@ -272,6 +273,26 @@ class ClassLoader | ||
272 | } | 273 | } |
273 | 274 | ||
274 | /** | 275 | /** |
276 | + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. | ||
277 | + * | ||
278 | + * @param string|null $apcuPrefix | ||
279 | + */ | ||
280 | + public function setApcuPrefix($apcuPrefix) | ||
281 | + { | ||
282 | + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; | ||
283 | + } | ||
284 | + | ||
285 | + /** | ||
286 | + * The APCu prefix in use, or null if APCu caching is not enabled. | ||
287 | + * | ||
288 | + * @return string|null | ||
289 | + */ | ||
290 | + public function getApcuPrefix() | ||
291 | + { | ||
292 | + return $this->apcuPrefix; | ||
293 | + } | ||
294 | + | ||
295 | + /** | ||
275 | * Registers this instance as an autoloader. | 296 | * Registers this instance as an autoloader. |
276 | * | 297 | * |
277 | * @param bool $prepend Whether to prepend the autoloader or not | 298 | * @param bool $prepend Whether to prepend the autoloader or not |
@@ -313,11 +334,6 @@ class ClassLoader | @@ -313,11 +334,6 @@ class ClassLoader | ||
313 | */ | 334 | */ |
314 | public function findFile($class) | 335 | public function findFile($class) |
315 | { | 336 | { |
316 | - // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 | ||
317 | - if ('\\' == $class[0]) { | ||
318 | - $class = substr($class, 1); | ||
319 | - } | ||
320 | - | ||
321 | // class map lookup | 337 | // class map lookup |
322 | if (isset($this->classMap[$class])) { | 338 | if (isset($this->classMap[$class])) { |
323 | return $this->classMap[$class]; | 339 | return $this->classMap[$class]; |
@@ -325,6 +341,12 @@ class ClassLoader | @@ -325,6 +341,12 @@ class ClassLoader | ||
325 | if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { | 341 | if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
326 | return false; | 342 | return false; |
327 | } | 343 | } |
344 | + if (null !== $this->apcuPrefix) { | ||
345 | + $file = apcu_fetch($this->apcuPrefix.$class, $hit); | ||
346 | + if ($hit) { | ||
347 | + return $file; | ||
348 | + } | ||
349 | + } | ||
328 | 350 | ||
329 | $file = $this->findFileWithExtension($class, '.php'); | 351 | $file = $this->findFileWithExtension($class, '.php'); |
330 | 352 | ||
@@ -333,6 +355,10 @@ class ClassLoader | @@ -333,6 +355,10 @@ class ClassLoader | ||
333 | $file = $this->findFileWithExtension($class, '.hh'); | 355 | $file = $this->findFileWithExtension($class, '.hh'); |
334 | } | 356 | } |
335 | 357 | ||
358 | + if (null !== $this->apcuPrefix) { | ||
359 | + apcu_add($this->apcuPrefix.$class, $file); | ||
360 | + } | ||
361 | + | ||
336 | if (false === $file) { | 362 | if (false === $file) { |
337 | // Remember that this class does not exist. | 363 | // Remember that this class does not exist. |
338 | $this->missingClasses[$class] = true; | 364 | $this->missingClasses[$class] = true; |
@@ -348,10 +374,14 @@ class ClassLoader | @@ -348,10 +374,14 @@ class ClassLoader | ||
348 | 374 | ||
349 | $first = $class[0]; | 375 | $first = $class[0]; |
350 | if (isset($this->prefixLengthsPsr4[$first])) { | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
351 | - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { | ||
352 | - if (0 === strpos($class, $prefix)) { | ||
353 | - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { | ||
354 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { | 377 | + $subPath = $class; |
378 | + while (false !== $lastPos = strrpos($subPath, '\\')) { | ||
379 | + $subPath = substr($subPath, 0, $lastPos); | ||
380 | + $search = $subPath . '\\'; | ||
381 | + if (isset($this->prefixDirsPsr4[$search])) { | ||
382 | + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); | ||
383 | + foreach ($this->prefixDirsPsr4[$search] as $dir) { | ||
384 | + if (file_exists($file = $dir . $pathEnd)) { | ||
355 | return $file; | 385 | return $file; |
356 | } | 386 | } |
357 | } | 387 | } |
1 | 1 | ||
2 | -Copyright (c) 2016 Nils Adermann, Jordi Boggiano | 2 | +Copyright (c) Nils Adermann, Jordi Boggiano |
3 | 3 | ||
4 | Permission is hereby granted, free of charge, to any person obtaining a copy | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
5 | of this software and associated documentation files (the "Software"), to deal | 5 | of this software and associated documentation files (the "Software"), to deal |
@@ -6,19 +6,12 @@ $vendorDir = dirname(dirname(__FILE__)); | @@ -6,19 +6,12 @@ $vendorDir = dirname(dirname(__FILE__)); | ||
6 | $baseDir = dirname($vendorDir); | 6 | $baseDir = dirname($vendorDir); |
7 | 7 | ||
8 | return array( | 8 | return array( |
9 | - 'ArithmeticError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php', | ||
10 | - 'AssertionError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php', | ||
11 | - 'DivisionByZeroError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php', | ||
12 | 'EasyPeasyICS' => $vendorDir . '/phpmailer/phpmailer/extras/EasyPeasyICS.php', | 9 | 'EasyPeasyICS' => $vendorDir . '/phpmailer/phpmailer/extras/EasyPeasyICS.php', |
13 | - 'Error' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/Error.php', | ||
14 | 'PHPMailer' => $vendorDir . '/phpmailer/phpmailer/class.phpmailer.php', | 10 | 'PHPMailer' => $vendorDir . '/phpmailer/phpmailer/class.phpmailer.php', |
15 | 'PHPMailerOAuth' => $vendorDir . '/phpmailer/phpmailer/class.phpmaileroauth.php', | 11 | 'PHPMailerOAuth' => $vendorDir . '/phpmailer/phpmailer/class.phpmaileroauth.php', |
16 | 'PHPMailerOAuthGoogle' => $vendorDir . '/phpmailer/phpmailer/class.phpmaileroauthgoogle.php', | 12 | 'PHPMailerOAuthGoogle' => $vendorDir . '/phpmailer/phpmailer/class.phpmaileroauthgoogle.php', |
17 | 'POP3' => $vendorDir . '/phpmailer/phpmailer/class.pop3.php', | 13 | 'POP3' => $vendorDir . '/phpmailer/phpmailer/class.pop3.php', |
18 | - 'ParseError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ParseError.php', | ||
19 | 'SMTP' => $vendorDir . '/phpmailer/phpmailer/class.smtp.php', | 14 | 'SMTP' => $vendorDir . '/phpmailer/phpmailer/class.smtp.php', |
20 | - 'SessionUpdateTimestampHandlerInterface' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php', | ||
21 | - 'TypeError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/TypeError.php', | ||
22 | 'ntlm_sasl_client_class' => $vendorDir . '/phpmailer/phpmailer/extras/ntlm_sasl_client.php', | 15 | 'ntlm_sasl_client_class' => $vendorDir . '/phpmailer/phpmailer/extras/ntlm_sasl_client.php', |
23 | 'phpmailerException' => $vendorDir . '/phpmailer/phpmailer/class.phpmailer.php', | 16 | 'phpmailerException' => $vendorDir . '/phpmailer/phpmailer/class.phpmailer.php', |
24 | ); | 17 | ); |
@@ -6,29 +6,13 @@ $vendorDir = dirname(dirname(__FILE__)); | @@ -6,29 +6,13 @@ $vendorDir = dirname(dirname(__FILE__)); | ||
6 | $baseDir = dirname($vendorDir); | 6 | $baseDir = dirname($vendorDir); |
7 | 7 | ||
8 | return array( | 8 | return array( |
9 | - '023d27dca8066ef29e6739335ea73bad' => $vendorDir . '/symfony/polyfill-php70/bootstrap.php', | ||
10 | '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', | 9 | '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', |
10 | + '25072dd6e2470089de65ae7bf11d3109' => $vendorDir . '/symfony/polyfill-php72/bootstrap.php', | ||
11 | + 'f598d06aa772fa33d905e87be6398fb1' => $vendorDir . '/symfony/polyfill-intl-idn/bootstrap.php', | ||
11 | '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', | 12 | '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', |
12 | 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', | 13 | 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', |
13 | 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', | 14 | 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', |
14 | '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', | 15 | '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', |
15 | - '9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php', | ||
16 | - '9d8e013a5160a09477beb8e44f8ae97b' => $vendorDir . '/markbaker/matrix/classes/src/functions/adjoint.php', | ||
17 | - '6e78d1bdea6248d6aa117229efae50f2' => $vendorDir . '/markbaker/matrix/classes/src/functions/antidiagonal.php', | ||
18 | - '4623d87924d94f5412fe5afbf1cef31d' => $vendorDir . '/markbaker/matrix/classes/src/functions/cofactors.php', | ||
19 | - '901fd1f6950a637ca85f66b701a45e13' => $vendorDir . '/markbaker/matrix/classes/src/functions/determinant.php', | ||
20 | - '83057abc0e4acc99ba80154ee5d02a49' => $vendorDir . '/markbaker/matrix/classes/src/functions/diagonal.php', | ||
21 | - '07b7fd7a434451149b4fd477fca0ce06' => $vendorDir . '/markbaker/matrix/classes/src/functions/identity.php', | ||
22 | - 'c8d43b340583e07ae89f2a3baef2cf89' => $vendorDir . '/markbaker/matrix/classes/src/functions/inverse.php', | ||
23 | - '499bb10ed7a3aee2ba4c09a31a85e8d1' => $vendorDir . '/markbaker/matrix/classes/src/functions/minors.php', | ||
24 | - '1cad2e6414d652e8b1c64e8967f6f37d' => $vendorDir . '/markbaker/matrix/classes/src/functions/trace.php', | ||
25 | - '95a7f134ac17161d07def442b3b737e8' => $vendorDir . '/markbaker/matrix/classes/src/functions/transpose.php', | ||
26 | - 'b3a6bc628377118d4b4b8ba08d1eb949' => $vendorDir . '/markbaker/matrix/classes/src/operations/add.php', | ||
27 | - '5fef6d0e407f3f8887266dfa4a6c534c' => $vendorDir . '/markbaker/matrix/classes/src/operations/directsum.php', | ||
28 | - '684ba247e1385946e3babdaa054119de' => $vendorDir . '/markbaker/matrix/classes/src/operations/subtract.php', | ||
29 | - 'aa53dcba601214d17ad405b7c291b7e8' => $vendorDir . '/markbaker/matrix/classes/src/operations/multiply.php', | ||
30 | - '75c79eb1b25749b05a47976f32b0d8a2' => $vendorDir . '/markbaker/matrix/classes/src/operations/divideby.php', | ||
31 | - '6ab8ad87a734f276a6bcd5a0fe1289be' => $vendorDir . '/markbaker/matrix/classes/src/operations/divideinto.php', | ||
32 | 'abede361264e2ae69ec1eee813a101af' => $vendorDir . '/markbaker/complex/classes/src/functions/abs.php', | 16 | 'abede361264e2ae69ec1eee813a101af' => $vendorDir . '/markbaker/complex/classes/src/functions/abs.php', |
33 | '21a5860fbef5be28db5ddfbc3cca67c4' => $vendorDir . '/markbaker/complex/classes/src/functions/acos.php', | 17 | '21a5860fbef5be28db5ddfbc3cca67c4' => $vendorDir . '/markbaker/complex/classes/src/functions/acos.php', |
34 | '1546e3f9d127f2a9bb2d1b6c31c26ef1' => $vendorDir . '/markbaker/complex/classes/src/functions/acosh.php', | 18 | '1546e3f9d127f2a9bb2d1b6c31c26ef1' => $vendorDir . '/markbaker/complex/classes/src/functions/acosh.php', |
@@ -71,7 +55,25 @@ return array( | @@ -71,7 +55,25 @@ return array( | ||
71 | '883af48563631547925fa4c3b48ead07' => $vendorDir . '/markbaker/complex/classes/src/operations/multiply.php', | 55 | '883af48563631547925fa4c3b48ead07' => $vendorDir . '/markbaker/complex/classes/src/operations/multiply.php', |
72 | 'f190e3308e6ca23234a2875edc985c03' => $vendorDir . '/markbaker/complex/classes/src/operations/divideby.php', | 56 | 'f190e3308e6ca23234a2875edc985c03' => $vendorDir . '/markbaker/complex/classes/src/operations/divideby.php', |
73 | 'ac9e33ce6841aa5bf5d16d465a2f03a7' => $vendorDir . '/markbaker/complex/classes/src/operations/divideinto.php', | 57 | 'ac9e33ce6841aa5bf5d16d465a2f03a7' => $vendorDir . '/markbaker/complex/classes/src/operations/divideinto.php', |
74 | - '9e090711773bfc38738f5dbaee5a7f14' => $vendorDir . '/overtrue/wechat/src/Payment/helpers.php', | ||
75 | - '1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php', | 58 | + '9d8e013a5160a09477beb8e44f8ae97b' => $vendorDir . '/markbaker/matrix/classes/src/functions/adjoint.php', |
59 | + '6e78d1bdea6248d6aa117229efae50f2' => $vendorDir . '/markbaker/matrix/classes/src/functions/antidiagonal.php', | ||
60 | + '4623d87924d94f5412fe5afbf1cef31d' => $vendorDir . '/markbaker/matrix/classes/src/functions/cofactors.php', | ||
61 | + '901fd1f6950a637ca85f66b701a45e13' => $vendorDir . '/markbaker/matrix/classes/src/functions/determinant.php', | ||
62 | + '83057abc0e4acc99ba80154ee5d02a49' => $vendorDir . '/markbaker/matrix/classes/src/functions/diagonal.php', | ||
63 | + '07b7fd7a434451149b4fd477fca0ce06' => $vendorDir . '/markbaker/matrix/classes/src/functions/identity.php', | ||
64 | + 'c8d43b340583e07ae89f2a3baef2cf89' => $vendorDir . '/markbaker/matrix/classes/src/functions/inverse.php', | ||
65 | + '499bb10ed7a3aee2ba4c09a31a85e8d1' => $vendorDir . '/markbaker/matrix/classes/src/functions/minors.php', | ||
66 | + '1cad2e6414d652e8b1c64e8967f6f37d' => $vendorDir . '/markbaker/matrix/classes/src/functions/trace.php', | ||
67 | + '95a7f134ac17161d07def442b3b737e8' => $vendorDir . '/markbaker/matrix/classes/src/functions/transpose.php', | ||
68 | + 'b3a6bc628377118d4b4b8ba08d1eb949' => $vendorDir . '/markbaker/matrix/classes/src/operations/add.php', | ||
69 | + '5fef6d0e407f3f8887266dfa4a6c534c' => $vendorDir . '/markbaker/matrix/classes/src/operations/directsum.php', | ||
70 | + '684ba247e1385946e3babdaa054119de' => $vendorDir . '/markbaker/matrix/classes/src/operations/subtract.php', | ||
71 | + 'aa53dcba601214d17ad405b7c291b7e8' => $vendorDir . '/markbaker/matrix/classes/src/operations/multiply.php', | ||
72 | + '75c79eb1b25749b05a47976f32b0d8a2' => $vendorDir . '/markbaker/matrix/classes/src/operations/divideby.php', | ||
73 | + '6ab8ad87a734f276a6bcd5a0fe1289be' => $vendorDir . '/markbaker/matrix/classes/src/operations/divideinto.php', | ||
74 | + '9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php', | ||
76 | '488987c28e9b5e95a1ce6b6bcb94606c' => $vendorDir . '/karsonzhang/fastadmin-addons/src/common.php', | 75 | '488987c28e9b5e95a1ce6b6bcb94606c' => $vendorDir . '/karsonzhang/fastadmin-addons/src/common.php', |
76 | + 'f0e7e63bbb278a92db02393536748c5f' => $vendorDir . '/overtrue/wechat/src/Kernel/Support/Helpers.php', | ||
77 | + '6747f579ad6817f318cc3a7e7a0abb93' => $vendorDir . '/overtrue/wechat/src/Kernel/Helpers.php', | ||
78 | + '1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php', | ||
77 | ); | 79 | ); |
@@ -7,5 +7,4 @@ $baseDir = dirname($vendorDir); | @@ -7,5 +7,4 @@ $baseDir = dirname($vendorDir); | ||
7 | 7 | ||
8 | return array( | 8 | return array( |
9 | 'Pimple' => array($vendorDir . '/pimple/pimple/src'), | 9 | 'Pimple' => array($vendorDir . '/pimple/pimple/src'), |
10 | - 'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib'), | ||
11 | ); | 10 | ); |
@@ -9,16 +9,25 @@ return array( | @@ -9,16 +9,25 @@ return array( | ||
9 | 'think\\helper\\' => array($vendorDir . '/topthink/think-helper/src'), | 9 | 'think\\helper\\' => array($vendorDir . '/topthink/think-helper/src'), |
10 | 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), | 10 | 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), |
11 | 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), | 11 | 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), |
12 | - 'think\\' => array($baseDir . '/thinkphp/library/think', $vendorDir . '/karsonzhang/fastadmin-addons/src'), | ||
13 | - 'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'), | 12 | + 'think\\' => array($vendorDir . '/karsonzhang/fastadmin-addons/src', $baseDir . '/thinkphp/library/think'), |
13 | + 'Symfony\\Polyfill\\Php72\\' => array($vendorDir . '/symfony/polyfill-php72'), | ||
14 | 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), | 14 | 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), |
15 | + 'Symfony\\Polyfill\\Intl\\Idn\\' => array($vendorDir . '/symfony/polyfill-intl-idn'), | ||
16 | + 'Symfony\\Contracts\\Service\\' => array($vendorDir . '/symfony/service-contracts'), | ||
17 | + 'Symfony\\Contracts\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher-contracts'), | ||
18 | + 'Symfony\\Contracts\\Cache\\' => array($vendorDir . '/symfony/cache-contracts'), | ||
19 | + 'Symfony\\Component\\VarExporter\\' => array($vendorDir . '/symfony/var-exporter'), | ||
15 | 'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'), | 20 | 'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'), |
21 | + 'Symfony\\Component\\Mime\\' => array($vendorDir . '/symfony/mime'), | ||
16 | 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), | 22 | 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), |
23 | + 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), | ||
24 | + 'Symfony\\Component\\Cache\\' => array($vendorDir . '/symfony/cache'), | ||
17 | 'Symfony\\Bridge\\PsrHttpMessage\\' => array($vendorDir . '/symfony/psr-http-message-bridge'), | 25 | 'Symfony\\Bridge\\PsrHttpMessage\\' => array($vendorDir . '/symfony/psr-http-message-bridge'), |
18 | 'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'), | 26 | 'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'), |
19 | 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), | 27 | 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), |
20 | 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), | 28 | 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), |
21 | 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), | 29 | 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), |
30 | + 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), | ||
22 | 'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'), | 31 | 'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'), |
23 | 'Overtrue\\Socialite\\' => array($vendorDir . '/overtrue/socialite/src'), | 32 | 'Overtrue\\Socialite\\' => array($vendorDir . '/overtrue/socialite/src'), |
24 | 'Overtrue\\Pinyin\\' => array($vendorDir . '/overtrue/pinyin/src'), | 33 | 'Overtrue\\Pinyin\\' => array($vendorDir . '/overtrue/pinyin/src'), |
@@ -29,6 +38,7 @@ return array( | @@ -29,6 +38,7 @@ return array( | ||
29 | 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), | 38 | 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), |
30 | 'Endroid\\QrCode\\' => array($vendorDir . '/endroid/qr-code/src'), | 39 | 'Endroid\\QrCode\\' => array($vendorDir . '/endroid/qr-code/src'), |
31 | 'EasyWeChat\\' => array($vendorDir . '/overtrue/wechat/src'), | 40 | 'EasyWeChat\\' => array($vendorDir . '/overtrue/wechat/src'), |
41 | + 'EasyWeChatComposer\\' => array($vendorDir . '/easywechat-composer/easywechat-composer/src'), | ||
32 | 'Cron\\' => array($vendorDir . '/mtdowling/cron-expression/src/Cron'), | 42 | 'Cron\\' => array($vendorDir . '/mtdowling/cron-expression/src/Cron'), |
33 | 'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'), | 43 | 'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'), |
34 | ); | 44 | ); |
@@ -23,7 +23,7 @@ class ComposerAutoloaderInit2537a12e3b63e265e25ee9e73315e195 | @@ -23,7 +23,7 @@ class ComposerAutoloaderInit2537a12e3b63e265e25ee9e73315e195 | ||
23 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(); | 23 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(); |
24 | spl_autoload_unregister(array('ComposerAutoloaderInit2537a12e3b63e265e25ee9e73315e195', 'loadClassLoader')); | 24 | spl_autoload_unregister(array('ComposerAutoloaderInit2537a12e3b63e265e25ee9e73315e195', 'loadClassLoader')); |
25 | 25 | ||
26 | - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); | 26 | + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
27 | if ($useStaticLoader) { | 27 | if ($useStaticLoader) { |
28 | require_once __DIR__ . '/autoload_static.php'; | 28 | require_once __DIR__ . '/autoload_static.php'; |
29 | 29 |
@@ -7,29 +7,13 @@ namespace Composer\Autoload; | @@ -7,29 +7,13 @@ namespace Composer\Autoload; | ||
7 | class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | 7 | class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 |
8 | { | 8 | { |
9 | public static $files = array ( | 9 | public static $files = array ( |
10 | - '023d27dca8066ef29e6739335ea73bad' => __DIR__ . '/..' . '/symfony/polyfill-php70/bootstrap.php', | ||
11 | '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', | 10 | '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', |
11 | + '25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php', | ||
12 | + 'f598d06aa772fa33d905e87be6398fb1' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/bootstrap.php', | ||
12 | '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', | 13 | '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', |
13 | 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', | 14 | 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', |
14 | 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', | 15 | 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', |
15 | '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', | 16 | '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', |
16 | - '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', | ||
17 | - '9d8e013a5160a09477beb8e44f8ae97b' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/adjoint.php', | ||
18 | - '6e78d1bdea6248d6aa117229efae50f2' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/antidiagonal.php', | ||
19 | - '4623d87924d94f5412fe5afbf1cef31d' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/cofactors.php', | ||
20 | - '901fd1f6950a637ca85f66b701a45e13' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/determinant.php', | ||
21 | - '83057abc0e4acc99ba80154ee5d02a49' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/diagonal.php', | ||
22 | - '07b7fd7a434451149b4fd477fca0ce06' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/identity.php', | ||
23 | - 'c8d43b340583e07ae89f2a3baef2cf89' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/inverse.php', | ||
24 | - '499bb10ed7a3aee2ba4c09a31a85e8d1' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/minors.php', | ||
25 | - '1cad2e6414d652e8b1c64e8967f6f37d' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/trace.php', | ||
26 | - '95a7f134ac17161d07def442b3b737e8' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/transpose.php', | ||
27 | - 'b3a6bc628377118d4b4b8ba08d1eb949' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/add.php', | ||
28 | - '5fef6d0e407f3f8887266dfa4a6c534c' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/directsum.php', | ||
29 | - '684ba247e1385946e3babdaa054119de' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/subtract.php', | ||
30 | - 'aa53dcba601214d17ad405b7c291b7e8' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/multiply.php', | ||
31 | - '75c79eb1b25749b05a47976f32b0d8a2' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/divideby.php', | ||
32 | - '6ab8ad87a734f276a6bcd5a0fe1289be' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/divideinto.php', | ||
33 | 'abede361264e2ae69ec1eee813a101af' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/abs.php', | 17 | 'abede361264e2ae69ec1eee813a101af' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/abs.php', |
34 | '21a5860fbef5be28db5ddfbc3cca67c4' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/acos.php', | 18 | '21a5860fbef5be28db5ddfbc3cca67c4' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/acos.php', |
35 | '1546e3f9d127f2a9bb2d1b6c31c26ef1' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/acosh.php', | 19 | '1546e3f9d127f2a9bb2d1b6c31c26ef1' => __DIR__ . '/..' . '/markbaker/complex/classes/src/functions/acosh.php', |
@@ -72,9 +56,27 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | @@ -72,9 +56,27 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | ||
72 | '883af48563631547925fa4c3b48ead07' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/multiply.php', | 56 | '883af48563631547925fa4c3b48ead07' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/multiply.php', |
73 | 'f190e3308e6ca23234a2875edc985c03' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/divideby.php', | 57 | 'f190e3308e6ca23234a2875edc985c03' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/divideby.php', |
74 | 'ac9e33ce6841aa5bf5d16d465a2f03a7' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/divideinto.php', | 58 | 'ac9e33ce6841aa5bf5d16d465a2f03a7' => __DIR__ . '/..' . '/markbaker/complex/classes/src/operations/divideinto.php', |
75 | - '9e090711773bfc38738f5dbaee5a7f14' => __DIR__ . '/..' . '/overtrue/wechat/src/Payment/helpers.php', | ||
76 | - '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', | 59 | + '9d8e013a5160a09477beb8e44f8ae97b' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/adjoint.php', |
60 | + '6e78d1bdea6248d6aa117229efae50f2' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/antidiagonal.php', | ||
61 | + '4623d87924d94f5412fe5afbf1cef31d' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/cofactors.php', | ||
62 | + '901fd1f6950a637ca85f66b701a45e13' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/determinant.php', | ||
63 | + '83057abc0e4acc99ba80154ee5d02a49' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/diagonal.php', | ||
64 | + '07b7fd7a434451149b4fd477fca0ce06' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/identity.php', | ||
65 | + 'c8d43b340583e07ae89f2a3baef2cf89' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/inverse.php', | ||
66 | + '499bb10ed7a3aee2ba4c09a31a85e8d1' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/minors.php', | ||
67 | + '1cad2e6414d652e8b1c64e8967f6f37d' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/trace.php', | ||
68 | + '95a7f134ac17161d07def442b3b737e8' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/functions/transpose.php', | ||
69 | + 'b3a6bc628377118d4b4b8ba08d1eb949' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/add.php', | ||
70 | + '5fef6d0e407f3f8887266dfa4a6c534c' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/directsum.php', | ||
71 | + '684ba247e1385946e3babdaa054119de' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/subtract.php', | ||
72 | + 'aa53dcba601214d17ad405b7c291b7e8' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/multiply.php', | ||
73 | + '75c79eb1b25749b05a47976f32b0d8a2' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/divideby.php', | ||
74 | + '6ab8ad87a734f276a6bcd5a0fe1289be' => __DIR__ . '/..' . '/markbaker/matrix/classes/src/operations/divideinto.php', | ||
75 | + '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', | ||
77 | '488987c28e9b5e95a1ce6b6bcb94606c' => __DIR__ . '/..' . '/karsonzhang/fastadmin-addons/src/common.php', | 76 | '488987c28e9b5e95a1ce6b6bcb94606c' => __DIR__ . '/..' . '/karsonzhang/fastadmin-addons/src/common.php', |
77 | + 'f0e7e63bbb278a92db02393536748c5f' => __DIR__ . '/..' . '/overtrue/wechat/src/Kernel/Support/Helpers.php', | ||
78 | + '6747f579ad6817f318cc3a7e7a0abb93' => __DIR__ . '/..' . '/overtrue/wechat/src/Kernel/Helpers.php', | ||
79 | + '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', | ||
78 | ); | 80 | ); |
79 | 81 | ||
80 | public static $prefixLengthsPsr4 = array ( | 82 | public static $prefixLengthsPsr4 = array ( |
@@ -87,10 +89,18 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | @@ -87,10 +89,18 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | ||
87 | ), | 89 | ), |
88 | 'S' => | 90 | 'S' => |
89 | array ( | 91 | array ( |
90 | - 'Symfony\\Polyfill\\Php70\\' => 23, | 92 | + 'Symfony\\Polyfill\\Php72\\' => 23, |
91 | 'Symfony\\Polyfill\\Mbstring\\' => 26, | 93 | 'Symfony\\Polyfill\\Mbstring\\' => 26, |
94 | + 'Symfony\\Polyfill\\Intl\\Idn\\' => 26, | ||
95 | + 'Symfony\\Contracts\\Service\\' => 26, | ||
96 | + 'Symfony\\Contracts\\EventDispatcher\\' => 34, | ||
97 | + 'Symfony\\Contracts\\Cache\\' => 24, | ||
98 | + 'Symfony\\Component\\VarExporter\\' => 30, | ||
92 | 'Symfony\\Component\\OptionsResolver\\' => 34, | 99 | 'Symfony\\Component\\OptionsResolver\\' => 34, |
100 | + 'Symfony\\Component\\Mime\\' => 23, | ||
93 | 'Symfony\\Component\\HttpFoundation\\' => 33, | 101 | 'Symfony\\Component\\HttpFoundation\\' => 33, |
102 | + 'Symfony\\Component\\EventDispatcher\\' => 34, | ||
103 | + 'Symfony\\Component\\Cache\\' => 24, | ||
94 | 'Symfony\\Bridge\\PsrHttpMessage\\' => 30, | 104 | 'Symfony\\Bridge\\PsrHttpMessage\\' => 30, |
95 | ), | 105 | ), |
96 | 'P' => | 106 | 'P' => |
@@ -99,6 +109,7 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | @@ -99,6 +109,7 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | ||
99 | 'Psr\\Log\\' => 8, | 109 | 'Psr\\Log\\' => 8, |
100 | 'Psr\\Http\\Message\\' => 17, | 110 | 'Psr\\Http\\Message\\' => 17, |
101 | 'Psr\\Container\\' => 14, | 111 | 'Psr\\Container\\' => 14, |
112 | + 'Psr\\Cache\\' => 10, | ||
102 | 'PhpOffice\\PhpSpreadsheet\\' => 25, | 113 | 'PhpOffice\\PhpSpreadsheet\\' => 25, |
103 | ), | 114 | ), |
104 | 'O' => | 115 | 'O' => |
@@ -121,6 +132,7 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | @@ -121,6 +132,7 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | ||
121 | array ( | 132 | array ( |
122 | 'Endroid\\QrCode\\' => 15, | 133 | 'Endroid\\QrCode\\' => 15, |
123 | 'EasyWeChat\\' => 11, | 134 | 'EasyWeChat\\' => 11, |
135 | + 'EasyWeChatComposer\\' => 19, | ||
124 | ), | 136 | ), |
125 | 'C' => | 137 | 'C' => |
126 | array ( | 138 | array ( |
@@ -144,25 +156,57 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | @@ -144,25 +156,57 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | ||
144 | ), | 156 | ), |
145 | 'think\\' => | 157 | 'think\\' => |
146 | array ( | 158 | array ( |
147 | - 0 => __DIR__ . '/../..' . '/thinkphp/library/think', | ||
148 | - 1 => __DIR__ . '/..' . '/karsonzhang/fastadmin-addons/src', | 159 | + 0 => __DIR__ . '/..' . '/karsonzhang/fastadmin-addons/src', |
160 | + 1 => __DIR__ . '/../..' . '/thinkphp/library/think', | ||
149 | ), | 161 | ), |
150 | - 'Symfony\\Polyfill\\Php70\\' => | 162 | + 'Symfony\\Polyfill\\Php72\\' => |
151 | array ( | 163 | array ( |
152 | - 0 => __DIR__ . '/..' . '/symfony/polyfill-php70', | 164 | + 0 => __DIR__ . '/..' . '/symfony/polyfill-php72', |
153 | ), | 165 | ), |
154 | 'Symfony\\Polyfill\\Mbstring\\' => | 166 | 'Symfony\\Polyfill\\Mbstring\\' => |
155 | array ( | 167 | array ( |
156 | 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', | 168 | 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', |
157 | ), | 169 | ), |
170 | + 'Symfony\\Polyfill\\Intl\\Idn\\' => | ||
171 | + array ( | ||
172 | + 0 => __DIR__ . '/..' . '/symfony/polyfill-intl-idn', | ||
173 | + ), | ||
174 | + 'Symfony\\Contracts\\Service\\' => | ||
175 | + array ( | ||
176 | + 0 => __DIR__ . '/..' . '/symfony/service-contracts', | ||
177 | + ), | ||
178 | + 'Symfony\\Contracts\\EventDispatcher\\' => | ||
179 | + array ( | ||
180 | + 0 => __DIR__ . '/..' . '/symfony/event-dispatcher-contracts', | ||
181 | + ), | ||
182 | + 'Symfony\\Contracts\\Cache\\' => | ||
183 | + array ( | ||
184 | + 0 => __DIR__ . '/..' . '/symfony/cache-contracts', | ||
185 | + ), | ||
186 | + 'Symfony\\Component\\VarExporter\\' => | ||
187 | + array ( | ||
188 | + 0 => __DIR__ . '/..' . '/symfony/var-exporter', | ||
189 | + ), | ||
158 | 'Symfony\\Component\\OptionsResolver\\' => | 190 | 'Symfony\\Component\\OptionsResolver\\' => |
159 | array ( | 191 | array ( |
160 | 0 => __DIR__ . '/..' . '/symfony/options-resolver', | 192 | 0 => __DIR__ . '/..' . '/symfony/options-resolver', |
161 | ), | 193 | ), |
194 | + 'Symfony\\Component\\Mime\\' => | ||
195 | + array ( | ||
196 | + 0 => __DIR__ . '/..' . '/symfony/mime', | ||
197 | + ), | ||
162 | 'Symfony\\Component\\HttpFoundation\\' => | 198 | 'Symfony\\Component\\HttpFoundation\\' => |
163 | array ( | 199 | array ( |
164 | 0 => __DIR__ . '/..' . '/symfony/http-foundation', | 200 | 0 => __DIR__ . '/..' . '/symfony/http-foundation', |
165 | ), | 201 | ), |
202 | + 'Symfony\\Component\\EventDispatcher\\' => | ||
203 | + array ( | ||
204 | + 0 => __DIR__ . '/..' . '/symfony/event-dispatcher', | ||
205 | + ), | ||
206 | + 'Symfony\\Component\\Cache\\' => | ||
207 | + array ( | ||
208 | + 0 => __DIR__ . '/..' . '/symfony/cache', | ||
209 | + ), | ||
166 | 'Symfony\\Bridge\\PsrHttpMessage\\' => | 210 | 'Symfony\\Bridge\\PsrHttpMessage\\' => |
167 | array ( | 211 | array ( |
168 | 0 => __DIR__ . '/..' . '/symfony/psr-http-message-bridge', | 212 | 0 => __DIR__ . '/..' . '/symfony/psr-http-message-bridge', |
@@ -183,6 +227,10 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | @@ -183,6 +227,10 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | ||
183 | array ( | 227 | array ( |
184 | 0 => __DIR__ . '/..' . '/psr/container/src', | 228 | 0 => __DIR__ . '/..' . '/psr/container/src', |
185 | ), | 229 | ), |
230 | + 'Psr\\Cache\\' => | ||
231 | + array ( | ||
232 | + 0 => __DIR__ . '/..' . '/psr/cache/src', | ||
233 | + ), | ||
186 | 'PhpOffice\\PhpSpreadsheet\\' => | 234 | 'PhpOffice\\PhpSpreadsheet\\' => |
187 | array ( | 235 | array ( |
188 | 0 => __DIR__ . '/..' . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet', | 236 | 0 => __DIR__ . '/..' . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet', |
@@ -223,6 +271,10 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | @@ -223,6 +271,10 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | ||
223 | array ( | 271 | array ( |
224 | 0 => __DIR__ . '/..' . '/overtrue/wechat/src', | 272 | 0 => __DIR__ . '/..' . '/overtrue/wechat/src', |
225 | ), | 273 | ), |
274 | + 'EasyWeChatComposer\\' => | ||
275 | + array ( | ||
276 | + 0 => __DIR__ . '/..' . '/easywechat-composer/easywechat-composer/src', | ||
277 | + ), | ||
226 | 'Cron\\' => | 278 | 'Cron\\' => |
227 | array ( | 279 | array ( |
228 | 0 => __DIR__ . '/..' . '/mtdowling/cron-expression/src/Cron', | 280 | 0 => __DIR__ . '/..' . '/mtdowling/cron-expression/src/Cron', |
@@ -241,29 +293,15 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | @@ -241,29 +293,15 @@ class ComposerStaticInit2537a12e3b63e265e25ee9e73315e195 | ||
241 | 0 => __DIR__ . '/..' . '/pimple/pimple/src', | 293 | 0 => __DIR__ . '/..' . '/pimple/pimple/src', |
242 | ), | 294 | ), |
243 | ), | 295 | ), |
244 | - 'D' => | ||
245 | - array ( | ||
246 | - 'Doctrine\\Common\\Cache\\' => | ||
247 | - array ( | ||
248 | - 0 => __DIR__ . '/..' . '/doctrine/cache/lib', | ||
249 | - ), | ||
250 | - ), | ||
251 | ); | 296 | ); |
252 | 297 | ||
253 | public static $classMap = array ( | 298 | public static $classMap = array ( |
254 | - 'ArithmeticError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php', | ||
255 | - 'AssertionError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php', | ||
256 | - 'DivisionByZeroError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php', | ||
257 | 'EasyPeasyICS' => __DIR__ . '/..' . '/phpmailer/phpmailer/extras/EasyPeasyICS.php', | 299 | 'EasyPeasyICS' => __DIR__ . '/..' . '/phpmailer/phpmailer/extras/EasyPeasyICS.php', |
258 | - 'Error' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/Error.php', | ||
259 | 'PHPMailer' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.phpmailer.php', | 300 | 'PHPMailer' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.phpmailer.php', |
260 | 'PHPMailerOAuth' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.phpmaileroauth.php', | 301 | 'PHPMailerOAuth' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.phpmaileroauth.php', |
261 | 'PHPMailerOAuthGoogle' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.phpmaileroauthgoogle.php', | 302 | 'PHPMailerOAuthGoogle' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.phpmaileroauthgoogle.php', |
262 | 'POP3' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.pop3.php', | 303 | 'POP3' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.pop3.php', |
263 | - 'ParseError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/ParseError.php', | ||
264 | 'SMTP' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.smtp.php', | 304 | 'SMTP' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.smtp.php', |
265 | - 'SessionUpdateTimestampHandlerInterface' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php', | ||
266 | - 'TypeError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/TypeError.php', | ||
267 | 'ntlm_sasl_client_class' => __DIR__ . '/..' . '/phpmailer/phpmailer/extras/ntlm_sasl_client.php', | 305 | 'ntlm_sasl_client_class' => __DIR__ . '/..' . '/phpmailer/phpmailer/extras/ntlm_sasl_client.php', |
268 | 'phpmailerException' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.phpmailer.php', | 306 | 'phpmailerException' => __DIR__ . '/..' . '/phpmailer/phpmailer/class.phpmailer.php', |
269 | ); | 307 | ); |
此 diff 太大无法显示。
vendor/doctrine/cache/.coveralls.yml
已删除
100644 → 0
vendor/doctrine/cache/.travis.yml
已删除
100644 → 0
1 | -language: php | ||
2 | - | ||
3 | -php: | ||
4 | - - 5.3 | ||
5 | - - 5.4 | ||
6 | - - 5.5 | ||
7 | - - 5.6 | ||
8 | - - hhvm | ||
9 | - | ||
10 | -services: | ||
11 | - - riak | ||
12 | - - mongodb | ||
13 | - - memcached | ||
14 | - - redis-server | ||
15 | - | ||
16 | -before_install: | ||
17 | - - sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ]; then pecl install riak-beta; fi" | ||
18 | - - sh -c "if [[ $TRAVIS_PHP_VERSION != 'hhvm' && `php-config --vernum` -ge 50500 ]] ; then pecl config-set preferred_state beta; printf "yes\n" | pecl install apcu ; else echo 'extension="apc.so"' >> ./tests/travis/php.ini ;fi" | ||
19 | - - composer self-update | ||
20 | - - sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ]; then phpenv config-add ./tests/travis/php.ini; fi" | ||
21 | - | ||
22 | -install: | ||
23 | - - composer --prefer-source --dev install | ||
24 | - | ||
25 | -script: | ||
26 | - - ./vendor/bin/phpunit -c ./tests/travis/phpunit.travis.xml -v | ||
27 | - | ||
28 | -after_script: | ||
29 | - - php vendor/bin/coveralls -v | ||
30 | - | ||
31 | -matrix: | ||
32 | - allow_failures: | ||
33 | - - php: hhvm |
vendor/doctrine/cache/LICENSE
已删除
100644 → 0
1 | -Copyright (c) 2006-2012 Doctrine Project | ||
2 | - | ||
3 | -Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
4 | -this software and associated documentation files (the "Software"), to deal in | ||
5 | -the Software without restriction, including without limitation the rights to | ||
6 | -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
7 | -of the Software, and to permit persons to whom the Software is furnished to do | ||
8 | -so, subject to the following conditions: | ||
9 | - | ||
10 | -The above copyright notice and this permission notice shall be included in all | ||
11 | -copies or substantial portions of the Software. | ||
12 | - | ||
13 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
14 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
15 | -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
16 | -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
17 | -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
18 | -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
19 | -SOFTWARE. |
vendor/doctrine/cache/README.md
已删除
100644 → 0
1 | -# Doctrine Cache | ||
2 | - | ||
3 | -Master: [](http://travis-ci.org/doctrine/cache) [](https://coveralls.io/r/doctrine/cache?branch=master) | ||
4 | - | ||
5 | -[](https://packagist.org/packages/doctrine/cache) [](https://packagist.org/packages/doctrine/cache) | ||
6 | - | ||
7 | -Cache component extracted from the Doctrine Common project. | ||
8 | - | ||
9 | -## Changelog | ||
10 | - | ||
11 | -### v1.2 | ||
12 | - | ||
13 | -* Added support for MongoDB as Cache Provider | ||
14 | -* Fix namespace version reset |
vendor/doctrine/cache/UPGRADE.md
已删除
100644 → 0
1 | -# Upgrade to 1.4 | ||
2 | - | ||
3 | -## Minor BC Break: `Doctrine\Common\Cache\FileCache#$extension` is now `private`. | ||
4 | - | ||
5 | -If you need to override the value of `Doctrine\Common\Cache\FileCache#$extension`, then use the | ||
6 | -second parameter of `Doctrine\Common\Cache\FileCache#__construct()` instead of overriding | ||
7 | -the property in your own implementation. | ||
8 | - | ||
9 | -## Minor BC Break: file based caches paths changed | ||
10 | - | ||
11 | -`Doctrine\Common\Cache\FileCache`, `Doctrine\Common\Cache\PhpFileCache` and | ||
12 | -`Doctrine\Common\Cache\FilesystemCache` are using a different cache paths structure. | ||
13 | - | ||
14 | -If you rely on warmed up caches for deployments, consider that caches generated | ||
15 | -with `doctrine/cache` `<1.4` are not compatible with the new directory structure, | ||
16 | -and will be ignored. |
vendor/doctrine/cache/build.properties
已删除
100644 → 0
vendor/doctrine/cache/build.xml
已删除
100644 → 0
1 | -<?xml version="1.0"?> | ||
2 | -<project name="DoctrineCommonCache" default="build" basedir="."> | ||
3 | - <property file="build.properties" /> | ||
4 | - | ||
5 | - <target name="php"> | ||
6 | - <exec executable="which" outputproperty="php_executable"> | ||
7 | - <arg value="php" /> | ||
8 | - </exec> | ||
9 | - </target> | ||
10 | - | ||
11 | - <target name="prepare"> | ||
12 | - <mkdir dir="build" /> | ||
13 | - </target> | ||
14 | - | ||
15 | - <target name="build" depends="check-git-checkout-clean,prepare,php,composer"> | ||
16 | - <exec executable="${php_executable}"> | ||
17 | - <arg value="build/composer.phar" /> | ||
18 | - <arg value="archive" /> | ||
19 | - <arg value="--dir=build" /> | ||
20 | - </exec> | ||
21 | - </target> | ||
22 | - | ||
23 | - <target name="composer" depends="php,composer-check,composer-download"> | ||
24 | - <exec executable="${php_executable}"> | ||
25 | - <arg value="build/composer.phar" /> | ||
26 | - <arg value="install" /> | ||
27 | - </exec> | ||
28 | - </target> | ||
29 | - | ||
30 | - <target name="composer-check" depends="prepare"> | ||
31 | - <available file="build/composer.phar" property="composer.present"/> | ||
32 | - </target> | ||
33 | - | ||
34 | - <target name="composer-download" unless="composer.present"> | ||
35 | - <exec executable="wget"> | ||
36 | - <arg value="-Obuild/composer.phar" /> | ||
37 | - <arg value="http://getcomposer.org/composer.phar" /> | ||
38 | - </exec> | ||
39 | - </target> | ||
40 | - | ||
41 | - <target name="make-release" depends="check-git-checkout-clean,prepare,php"> | ||
42 | - <replace file="${project.version_file}" token="-DEV" value="" failOnNoReplacements="true" /> | ||
43 | - <exec executable="git" failonerror="true" outputproperty="current_git_branch"> | ||
44 | - <arg value="rev-parse" /> | ||
45 | - <arg value="--abbrev-ref" /> | ||
46 | - <arg value="HEAD" /> | ||
47 | - </exec> | ||
48 | - <exec executable="${php_executable}" outputproperty="doctrine.current_version" failonerror="true"> | ||
49 | - <arg value="-r" /> | ||
50 | - <arg value="require_once '${project.version_file}';echo ${project.version_class}::VERSION;" /> | ||
51 | - </exec> | ||
52 | - <exec executable="${php_executable}" outputproperty="doctrine.next_version" failonerror="true"> | ||
53 | - <arg value="-r" /> | ||
54 | - <arg value="$parts = explode('.', str_ireplace(array('-DEV', '-ALPHA', '-BETA'), '', '${doctrine.current_version}')); | ||
55 | - if (count($parts) != 3) { | ||
56 | - throw new \InvalidArgumentException('Version is assumed in format x.y.z, ${doctrine.current_version} given'); | ||
57 | - } | ||
58 | - if ('${current_git_branch}' === 'master') { | ||
59 | - $parts[1]++; | ||
60 | - } else { | ||
61 | - $parts[2]++; | ||
62 | - } | ||
63 | - echo implode('.', $parts); | ||
64 | - " /> | ||
65 | - </exec> | ||
66 | - | ||
67 | - <git-commit file="${project.version_file}" message="Release ${doctrine.current_version}" /> | ||
68 | - <git-tag version="${doctrine.current_version}" /> | ||
69 | - <replace file="${project.version_file}" token="${doctrine.current_version}" value="${doctrine.next_version}-DEV" /> | ||
70 | - <git-commit file="${project.version_file}" message="Bump version to ${doctrine.next_version}" /> | ||
71 | - </target> | ||
72 | - | ||
73 | - <target name="check-git-checkout-clean"> | ||
74 | - <exec executable="git" failonerror="true"> | ||
75 | - <arg value="diff-index" /> | ||
76 | - <arg value="--quiet" /> | ||
77 | - <arg value="HEAD" /> | ||
78 | - </exec> | ||
79 | - </target> | ||
80 | - | ||
81 | - <macrodef name="git-commit"> | ||
82 | - <attribute name="file" default="NOT SET"/> | ||
83 | - <attribute name="message" default="NOT SET"/> | ||
84 | - | ||
85 | - <sequential> | ||
86 | - <exec executable="git"> | ||
87 | - <arg value="add" /> | ||
88 | - <arg value="@{file}" /> | ||
89 | - </exec> | ||
90 | - <exec executable="git"> | ||
91 | - <arg value="commit" /> | ||
92 | - <arg value="-m" /> | ||
93 | - <arg value="@{message}" /> | ||
94 | - </exec> | ||
95 | - </sequential> | ||
96 | - </macrodef> | ||
97 | - | ||
98 | - <macrodef name="git-tag"> | ||
99 | - <attribute name="version" default="NOT SET" /> | ||
100 | - | ||
101 | - <sequential> | ||
102 | - <exec executable="git"> | ||
103 | - <arg value="tag" /> | ||
104 | - <arg value="-m" /> | ||
105 | - <arg value="v@{version}" /> | ||
106 | - <arg value="v@{version}" /> | ||
107 | - </exec> | ||
108 | - </sequential> | ||
109 | - </macrodef> | ||
110 | -</project> |
vendor/doctrine/cache/composer.json
已删除
100644 → 0
1 | -{ | ||
2 | - "name": "doctrine/cache", | ||
3 | - "type": "library", | ||
4 | - "description": "Caching library offering an object-oriented API for many cache backends", | ||
5 | - "keywords": ["cache", "caching"], | ||
6 | - "homepage": "http://www.doctrine-project.org", | ||
7 | - "license": "MIT", | ||
8 | - "authors": [ | ||
9 | - {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"}, | ||
10 | - {"name": "Roman Borschel", "email": "roman@code-factory.org"}, | ||
11 | - {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"}, | ||
12 | - {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, | ||
13 | - {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} | ||
14 | - ], | ||
15 | - "require": { | ||
16 | - "php": ">=5.3.2" | ||
17 | - }, | ||
18 | - "require-dev": { | ||
19 | - "phpunit/phpunit": ">=3.7", | ||
20 | - "satooshi/php-coveralls": "~0.6", | ||
21 | - "predis/predis": "~1.0" | ||
22 | - }, | ||
23 | - "conflict": { | ||
24 | - "doctrine/common": ">2.2,<2.4" | ||
25 | - }, | ||
26 | - "autoload": { | ||
27 | - "psr-0": { "Doctrine\\Common\\Cache\\": "lib/" } | ||
28 | - }, | ||
29 | - "extra": { | ||
30 | - "branch-alias": { | ||
31 | - "dev-master": "1.5.x-dev" | ||
32 | - } | ||
33 | - } | ||
34 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * APC cache provider. | ||
24 | - * | ||
25 | - * @link www.doctrine-project.org | ||
26 | - * @since 2.0 | ||
27 | - * @author Benjamin Eberlei <kontakt@beberlei.de> | ||
28 | - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
29 | - * @author Jonathan Wage <jonwage@gmail.com> | ||
30 | - * @author Roman Borschel <roman@code-factory.org> | ||
31 | - * @author David Abdemoulaie <dave@hobodave.com> | ||
32 | - */ | ||
33 | -class ApcCache extends CacheProvider | ||
34 | -{ | ||
35 | - /** | ||
36 | - * {@inheritdoc} | ||
37 | - */ | ||
38 | - protected function doFetch($id) | ||
39 | - { | ||
40 | - return apc_fetch($id); | ||
41 | - } | ||
42 | - | ||
43 | - /** | ||
44 | - * {@inheritdoc} | ||
45 | - */ | ||
46 | - protected function doContains($id) | ||
47 | - { | ||
48 | - return apc_exists($id); | ||
49 | - } | ||
50 | - | ||
51 | - /** | ||
52 | - * {@inheritdoc} | ||
53 | - */ | ||
54 | - protected function doSave($id, $data, $lifeTime = 0) | ||
55 | - { | ||
56 | - return (bool) apc_store($id, $data, (int) $lifeTime); | ||
57 | - } | ||
58 | - | ||
59 | - /** | ||
60 | - * {@inheritdoc} | ||
61 | - */ | ||
62 | - protected function doDelete($id) | ||
63 | - { | ||
64 | - // apc_delete returns false if the id does not exist | ||
65 | - return apc_delete($id) || ! apc_exists($id); | ||
66 | - } | ||
67 | - | ||
68 | - /** | ||
69 | - * {@inheritdoc} | ||
70 | - */ | ||
71 | - protected function doFlush() | ||
72 | - { | ||
73 | - return apc_clear_cache() && apc_clear_cache('user'); | ||
74 | - } | ||
75 | - | ||
76 | - /** | ||
77 | - * {@inheritdoc} | ||
78 | - */ | ||
79 | - protected function doFetchMultiple(array $keys) | ||
80 | - { | ||
81 | - return apc_fetch($keys); | ||
82 | - } | ||
83 | - | ||
84 | - /** | ||
85 | - * {@inheritdoc} | ||
86 | - */ | ||
87 | - protected function doGetStats() | ||
88 | - { | ||
89 | - $info = apc_cache_info('', true); | ||
90 | - $sma = apc_sma_info(); | ||
91 | - | ||
92 | - // @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42 | ||
93 | - if (PHP_VERSION_ID >= 50500) { | ||
94 | - $info['num_hits'] = isset($info['num_hits']) ? $info['num_hits'] : $info['nhits']; | ||
95 | - $info['num_misses'] = isset($info['num_misses']) ? $info['num_misses'] : $info['nmisses']; | ||
96 | - $info['start_time'] = isset($info['start_time']) ? $info['start_time'] : $info['stime']; | ||
97 | - } | ||
98 | - | ||
99 | - return array( | ||
100 | - Cache::STATS_HITS => $info['num_hits'], | ||
101 | - Cache::STATS_MISSES => $info['num_misses'], | ||
102 | - Cache::STATS_UPTIME => $info['start_time'], | ||
103 | - Cache::STATS_MEMORY_USAGE => $info['mem_size'], | ||
104 | - Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem'], | ||
105 | - ); | ||
106 | - } | ||
107 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Array cache driver. | ||
24 | - * | ||
25 | - * @link www.doctrine-project.org | ||
26 | - * @since 2.0 | ||
27 | - * @author Benjamin Eberlei <kontakt@beberlei.de> | ||
28 | - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
29 | - * @author Jonathan Wage <jonwage@gmail.com> | ||
30 | - * @author Roman Borschel <roman@code-factory.org> | ||
31 | - * @author David Abdemoulaie <dave@hobodave.com> | ||
32 | - */ | ||
33 | -class ArrayCache extends CacheProvider | ||
34 | -{ | ||
35 | - /** | ||
36 | - * @var array $data | ||
37 | - */ | ||
38 | - private $data = array(); | ||
39 | - | ||
40 | - /** | ||
41 | - * {@inheritdoc} | ||
42 | - */ | ||
43 | - protected function doFetch($id) | ||
44 | - { | ||
45 | - return $this->doContains($id) ? $this->data[$id] : false; | ||
46 | - } | ||
47 | - | ||
48 | - /** | ||
49 | - * {@inheritdoc} | ||
50 | - */ | ||
51 | - protected function doContains($id) | ||
52 | - { | ||
53 | - // isset() is required for performance optimizations, to avoid unnecessary function calls to array_key_exists. | ||
54 | - return isset($this->data[$id]) || array_key_exists($id, $this->data); | ||
55 | - } | ||
56 | - | ||
57 | - /** | ||
58 | - * {@inheritdoc} | ||
59 | - */ | ||
60 | - protected function doSave($id, $data, $lifeTime = 0) | ||
61 | - { | ||
62 | - $this->data[$id] = $data; | ||
63 | - | ||
64 | - return true; | ||
65 | - } | ||
66 | - | ||
67 | - /** | ||
68 | - * {@inheritdoc} | ||
69 | - */ | ||
70 | - protected function doDelete($id) | ||
71 | - { | ||
72 | - unset($this->data[$id]); | ||
73 | - | ||
74 | - return true; | ||
75 | - } | ||
76 | - | ||
77 | - /** | ||
78 | - * {@inheritdoc} | ||
79 | - */ | ||
80 | - protected function doFlush() | ||
81 | - { | ||
82 | - $this->data = array(); | ||
83 | - | ||
84 | - return true; | ||
85 | - } | ||
86 | - | ||
87 | - /** | ||
88 | - * {@inheritdoc} | ||
89 | - */ | ||
90 | - protected function doGetStats() | ||
91 | - { | ||
92 | - return null; | ||
93 | - } | ||
94 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Interface for cache drivers. | ||
24 | - * | ||
25 | - * @link www.doctrine-project.org | ||
26 | - * @since 2.0 | ||
27 | - * @author Benjamin Eberlei <kontakt@beberlei.de> | ||
28 | - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
29 | - * @author Jonathan Wage <jonwage@gmail.com> | ||
30 | - * @author Roman Borschel <roman@code-factory.org> | ||
31 | - * @author Fabio B. Silva <fabio.bat.silva@gmail.com> | ||
32 | - * @author Kévin Dunglas <dunglas@gmail.com> | ||
33 | - */ | ||
34 | -interface Cache | ||
35 | -{ | ||
36 | - const STATS_HITS = 'hits'; | ||
37 | - const STATS_MISSES = 'misses'; | ||
38 | - const STATS_UPTIME = 'uptime'; | ||
39 | - const STATS_MEMORY_USAGE = 'memory_usage'; | ||
40 | - const STATS_MEMORY_AVAILABLE = 'memory_available'; | ||
41 | - /** | ||
42 | - * Only for backward compatibility (may be removed in next major release) | ||
43 | - * | ||
44 | - * @deprecated | ||
45 | - */ | ||
46 | - const STATS_MEMORY_AVAILIABLE = 'memory_available'; | ||
47 | - | ||
48 | - /** | ||
49 | - * Fetches an entry from the cache. | ||
50 | - * | ||
51 | - * @param string $id The id of the cache entry to fetch. | ||
52 | - * | ||
53 | - * @return mixed The cached data or FALSE, if no cache entry exists for the given id. | ||
54 | - */ | ||
55 | - public function fetch($id); | ||
56 | - | ||
57 | - /** | ||
58 | - * Tests if an entry exists in the cache. | ||
59 | - * | ||
60 | - * @param string $id The cache id of the entry to check for. | ||
61 | - * | ||
62 | - * @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise. | ||
63 | - */ | ||
64 | - public function contains($id); | ||
65 | - | ||
66 | - /** | ||
67 | - * Puts data into the cache. | ||
68 | - * | ||
69 | - * If a cache entry with the given id already exists, its data will be replaced. | ||
70 | - * | ||
71 | - * @param string $id The cache id. | ||
72 | - * @param mixed $data The cache entry/data. | ||
73 | - * @param int $lifeTime The lifetime in number of seconds for this cache entry. | ||
74 | - * If zero (the default), the entry never expires (although it may be deleted from the cache | ||
75 | - * to make place for other entries). | ||
76 | - * | ||
77 | - * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. | ||
78 | - */ | ||
79 | - public function save($id, $data, $lifeTime = 0); | ||
80 | - | ||
81 | - /** | ||
82 | - * Deletes a cache entry. | ||
83 | - * | ||
84 | - * @param string $id The cache id. | ||
85 | - * | ||
86 | - * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. | ||
87 | - * Deleting a non-existing entry is considered successful. | ||
88 | - */ | ||
89 | - public function delete($id); | ||
90 | - | ||
91 | - /** | ||
92 | - * Retrieves cached information from the data store. | ||
93 | - * | ||
94 | - * The server's statistics array has the following values: | ||
95 | - * | ||
96 | - * - <b>hits</b> | ||
97 | - * Number of keys that have been requested and found present. | ||
98 | - * | ||
99 | - * - <b>misses</b> | ||
100 | - * Number of items that have been requested and not found. | ||
101 | - * | ||
102 | - * - <b>uptime</b> | ||
103 | - * Time that the server is running. | ||
104 | - * | ||
105 | - * - <b>memory_usage</b> | ||
106 | - * Memory used by this server to store items. | ||
107 | - * | ||
108 | - * - <b>memory_available</b> | ||
109 | - * Memory allowed to use for storage. | ||
110 | - * | ||
111 | - * @since 2.2 | ||
112 | - * | ||
113 | - * @return array|null An associative array with server's statistics if available, NULL otherwise. | ||
114 | - */ | ||
115 | - public function getStats(); | ||
116 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Base class for cache provider implementations. | ||
24 | - * | ||
25 | - * @since 2.2 | ||
26 | - * @author Benjamin Eberlei <kontakt@beberlei.de> | ||
27 | - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
28 | - * @author Jonathan Wage <jonwage@gmail.com> | ||
29 | - * @author Roman Borschel <roman@code-factory.org> | ||
30 | - * @author Fabio B. Silva <fabio.bat.silva@gmail.com> | ||
31 | - */ | ||
32 | -abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, MultiGetCache | ||
33 | -{ | ||
34 | - const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]'; | ||
35 | - | ||
36 | - /** | ||
37 | - * The namespace to prefix all cache ids with. | ||
38 | - * | ||
39 | - * @var string | ||
40 | - */ | ||
41 | - private $namespace = ''; | ||
42 | - | ||
43 | - /** | ||
44 | - * The namespace version. | ||
45 | - * | ||
46 | - * @var integer|null | ||
47 | - */ | ||
48 | - private $namespaceVersion; | ||
49 | - | ||
50 | - /** | ||
51 | - * Sets the namespace to prefix all cache ids with. | ||
52 | - * | ||
53 | - * @param string $namespace | ||
54 | - * | ||
55 | - * @return void | ||
56 | - */ | ||
57 | - public function setNamespace($namespace) | ||
58 | - { | ||
59 | - $this->namespace = (string) $namespace; | ||
60 | - $this->namespaceVersion = null; | ||
61 | - } | ||
62 | - | ||
63 | - /** | ||
64 | - * Retrieves the namespace that prefixes all cache ids. | ||
65 | - * | ||
66 | - * @return string | ||
67 | - */ | ||
68 | - public function getNamespace() | ||
69 | - { | ||
70 | - return $this->namespace; | ||
71 | - } | ||
72 | - | ||
73 | - /** | ||
74 | - * {@inheritdoc} | ||
75 | - */ | ||
76 | - public function fetch($id) | ||
77 | - { | ||
78 | - return $this->doFetch($this->getNamespacedId($id)); | ||
79 | - } | ||
80 | - | ||
81 | - /** | ||
82 | - * {@inheritdoc} | ||
83 | - */ | ||
84 | - public function fetchMultiple(array $keys) | ||
85 | - { | ||
86 | - if (empty($keys)) { | ||
87 | - return array(); | ||
88 | - } | ||
89 | - | ||
90 | - // note: the array_combine() is in place to keep an association between our $keys and the $namespacedKeys | ||
91 | - $namespacedKeys = array_combine($keys, array_map(array($this, 'getNamespacedId'), $keys)); | ||
92 | - $items = $this->doFetchMultiple($namespacedKeys); | ||
93 | - $foundItems = array(); | ||
94 | - | ||
95 | - // no internal array function supports this sort of mapping: needs to be iterative | ||
96 | - // this filters and combines keys in one pass | ||
97 | - foreach ($namespacedKeys as $requestedKey => $namespacedKey) { | ||
98 | - if (isset($items[$namespacedKey]) || array_key_exists($namespacedKey, $items)) { | ||
99 | - $foundItems[$requestedKey] = $items[$namespacedKey]; | ||
100 | - } | ||
101 | - } | ||
102 | - | ||
103 | - return $foundItems; | ||
104 | - } | ||
105 | - | ||
106 | - /** | ||
107 | - * {@inheritdoc} | ||
108 | - */ | ||
109 | - public function contains($id) | ||
110 | - { | ||
111 | - return $this->doContains($this->getNamespacedId($id)); | ||
112 | - } | ||
113 | - | ||
114 | - /** | ||
115 | - * {@inheritdoc} | ||
116 | - */ | ||
117 | - public function save($id, $data, $lifeTime = 0) | ||
118 | - { | ||
119 | - return $this->doSave($this->getNamespacedId($id), $data, $lifeTime); | ||
120 | - } | ||
121 | - | ||
122 | - /** | ||
123 | - * {@inheritdoc} | ||
124 | - */ | ||
125 | - public function delete($id) | ||
126 | - { | ||
127 | - return $this->doDelete($this->getNamespacedId($id)); | ||
128 | - } | ||
129 | - | ||
130 | - /** | ||
131 | - * {@inheritdoc} | ||
132 | - */ | ||
133 | - public function getStats() | ||
134 | - { | ||
135 | - return $this->doGetStats(); | ||
136 | - } | ||
137 | - | ||
138 | - /** | ||
139 | - * {@inheritDoc} | ||
140 | - */ | ||
141 | - public function flushAll() | ||
142 | - { | ||
143 | - return $this->doFlush(); | ||
144 | - } | ||
145 | - | ||
146 | - /** | ||
147 | - * {@inheritDoc} | ||
148 | - */ | ||
149 | - public function deleteAll() | ||
150 | - { | ||
151 | - $namespaceCacheKey = $this->getNamespaceCacheKey(); | ||
152 | - $namespaceVersion = $this->getNamespaceVersion() + 1; | ||
153 | - | ||
154 | - if ($this->doSave($namespaceCacheKey, $namespaceVersion)) { | ||
155 | - $this->namespaceVersion = $namespaceVersion; | ||
156 | - | ||
157 | - return true; | ||
158 | - } | ||
159 | - | ||
160 | - return false; | ||
161 | - } | ||
162 | - | ||
163 | - /** | ||
164 | - * Prefixes the passed id with the configured namespace value. | ||
165 | - * | ||
166 | - * @param string $id The id to namespace. | ||
167 | - * | ||
168 | - * @return string The namespaced id. | ||
169 | - */ | ||
170 | - private function getNamespacedId($id) | ||
171 | - { | ||
172 | - $namespaceVersion = $this->getNamespaceVersion(); | ||
173 | - | ||
174 | - return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion); | ||
175 | - } | ||
176 | - | ||
177 | - /** | ||
178 | - * Returns the namespace cache key. | ||
179 | - * | ||
180 | - * @return string | ||
181 | - */ | ||
182 | - private function getNamespaceCacheKey() | ||
183 | - { | ||
184 | - return sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace); | ||
185 | - } | ||
186 | - | ||
187 | - /** | ||
188 | - * Returns the namespace version. | ||
189 | - * | ||
190 | - * @return integer | ||
191 | - */ | ||
192 | - private function getNamespaceVersion() | ||
193 | - { | ||
194 | - if (null !== $this->namespaceVersion) { | ||
195 | - return $this->namespaceVersion; | ||
196 | - } | ||
197 | - | ||
198 | - $namespaceCacheKey = $this->getNamespaceCacheKey(); | ||
199 | - $this->namespaceVersion = $this->doFetch($namespaceCacheKey) ?: 1; | ||
200 | - | ||
201 | - return $this->namespaceVersion; | ||
202 | - } | ||
203 | - | ||
204 | - /** | ||
205 | - * Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it. | ||
206 | - * | ||
207 | - * @param array $keys Array of keys to retrieve from cache | ||
208 | - * @return array Array of values retrieved for the given keys. | ||
209 | - */ | ||
210 | - protected function doFetchMultiple(array $keys) | ||
211 | - { | ||
212 | - $returnValues = array(); | ||
213 | - | ||
214 | - foreach ($keys as $index => $key) { | ||
215 | - if (false !== ($item = $this->doFetch($key))) { | ||
216 | - $returnValues[$key] = $item; | ||
217 | - } | ||
218 | - } | ||
219 | - | ||
220 | - return $returnValues; | ||
221 | - } | ||
222 | - | ||
223 | - /** | ||
224 | - * Fetches an entry from the cache. | ||
225 | - * | ||
226 | - * @param string $id The id of the cache entry to fetch. | ||
227 | - * | ||
228 | - * @return mixed|boolean The cached data or FALSE, if no cache entry exists for the given id. | ||
229 | - */ | ||
230 | - abstract protected function doFetch($id); | ||
231 | - | ||
232 | - /** | ||
233 | - * Tests if an entry exists in the cache. | ||
234 | - * | ||
235 | - * @param string $id The cache id of the entry to check for. | ||
236 | - * | ||
237 | - * @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise. | ||
238 | - */ | ||
239 | - abstract protected function doContains($id); | ||
240 | - | ||
241 | - /** | ||
242 | - * Puts data into the cache. | ||
243 | - * | ||
244 | - * @param string $id The cache id. | ||
245 | - * @param string $data The cache entry/data. | ||
246 | - * @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this | ||
247 | - * cache entry (0 => infinite lifeTime). | ||
248 | - * | ||
249 | - * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. | ||
250 | - */ | ||
251 | - abstract protected function doSave($id, $data, $lifeTime = 0); | ||
252 | - | ||
253 | - /** | ||
254 | - * Deletes a cache entry. | ||
255 | - * | ||
256 | - * @param string $id The cache id. | ||
257 | - * | ||
258 | - * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. | ||
259 | - */ | ||
260 | - abstract protected function doDelete($id); | ||
261 | - | ||
262 | - /** | ||
263 | - * Flushes all cache entries. | ||
264 | - * | ||
265 | - * @return boolean TRUE if the cache entries were successfully flushed, FALSE otherwise. | ||
266 | - */ | ||
267 | - abstract protected function doFlush(); | ||
268 | - | ||
269 | - /** | ||
270 | - * Retrieves cached information from the data store. | ||
271 | - * | ||
272 | - * @since 2.2 | ||
273 | - * | ||
274 | - * @return array|null An associative array with server's statistics if available, NULL otherwise. | ||
275 | - */ | ||
276 | - abstract protected function doGetStats(); | ||
277 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Cache provider that allows to easily chain multiple cache providers | ||
24 | - * | ||
25 | - * @author Michaël Gallego <mic.gallego@gmail.com> | ||
26 | - */ | ||
27 | -class ChainCache extends CacheProvider | ||
28 | -{ | ||
29 | - /** | ||
30 | - * @var CacheProvider[] | ||
31 | - */ | ||
32 | - private $cacheProviders = array(); | ||
33 | - | ||
34 | - /** | ||
35 | - * Constructor | ||
36 | - * | ||
37 | - * @param CacheProvider[] $cacheProviders | ||
38 | - */ | ||
39 | - public function __construct($cacheProviders = array()) | ||
40 | - { | ||
41 | - $this->cacheProviders = $cacheProviders; | ||
42 | - } | ||
43 | - | ||
44 | - /** | ||
45 | - * {@inheritDoc} | ||
46 | - */ | ||
47 | - public function setNamespace($namespace) | ||
48 | - { | ||
49 | - parent::setNamespace($namespace); | ||
50 | - | ||
51 | - foreach ($this->cacheProviders as $cacheProvider) { | ||
52 | - $cacheProvider->setNamespace($namespace); | ||
53 | - } | ||
54 | - } | ||
55 | - | ||
56 | - /** | ||
57 | - * {@inheritDoc} | ||
58 | - */ | ||
59 | - protected function doFetch($id) | ||
60 | - { | ||
61 | - foreach ($this->cacheProviders as $key => $cacheProvider) { | ||
62 | - if ($cacheProvider->doContains($id)) { | ||
63 | - $value = $cacheProvider->doFetch($id); | ||
64 | - | ||
65 | - // We populate all the previous cache layers (that are assumed to be faster) | ||
66 | - for ($subKey = $key - 1 ; $subKey >= 0 ; $subKey--) { | ||
67 | - $this->cacheProviders[$subKey]->doSave($id, $value); | ||
68 | - } | ||
69 | - | ||
70 | - return $value; | ||
71 | - } | ||
72 | - } | ||
73 | - | ||
74 | - return false; | ||
75 | - } | ||
76 | - | ||
77 | - /** | ||
78 | - * {@inheritDoc} | ||
79 | - */ | ||
80 | - protected function doContains($id) | ||
81 | - { | ||
82 | - foreach ($this->cacheProviders as $cacheProvider) { | ||
83 | - if ($cacheProvider->doContains($id)) { | ||
84 | - return true; | ||
85 | - } | ||
86 | - } | ||
87 | - | ||
88 | - return false; | ||
89 | - } | ||
90 | - | ||
91 | - /** | ||
92 | - * {@inheritDoc} | ||
93 | - */ | ||
94 | - protected function doSave($id, $data, $lifeTime = 0) | ||
95 | - { | ||
96 | - $stored = true; | ||
97 | - | ||
98 | - foreach ($this->cacheProviders as $cacheProvider) { | ||
99 | - $stored = $cacheProvider->doSave($id, $data, $lifeTime) && $stored; | ||
100 | - } | ||
101 | - | ||
102 | - return $stored; | ||
103 | - } | ||
104 | - | ||
105 | - /** | ||
106 | - * {@inheritDoc} | ||
107 | - */ | ||
108 | - protected function doDelete($id) | ||
109 | - { | ||
110 | - $deleted = true; | ||
111 | - | ||
112 | - foreach ($this->cacheProviders as $cacheProvider) { | ||
113 | - $deleted = $cacheProvider->doDelete($id) && $deleted; | ||
114 | - } | ||
115 | - | ||
116 | - return $deleted; | ||
117 | - } | ||
118 | - | ||
119 | - /** | ||
120 | - * {@inheritDoc} | ||
121 | - */ | ||
122 | - protected function doFlush() | ||
123 | - { | ||
124 | - $flushed = true; | ||
125 | - | ||
126 | - foreach ($this->cacheProviders as $cacheProvider) { | ||
127 | - $flushed = $cacheProvider->doFlush() && $flushed; | ||
128 | - } | ||
129 | - | ||
130 | - return $flushed; | ||
131 | - } | ||
132 | - | ||
133 | - /** | ||
134 | - * {@inheritDoc} | ||
135 | - */ | ||
136 | - protected function doGetStats() | ||
137 | - { | ||
138 | - // We return all the stats from all adapters | ||
139 | - $stats = array(); | ||
140 | - | ||
141 | - foreach ($this->cacheProviders as $cacheProvider) { | ||
142 | - $stats[] = $cacheProvider->doGetStats(); | ||
143 | - } | ||
144 | - | ||
145 | - return $stats; | ||
146 | - } | ||
147 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Interface for cache that can be flushed. | ||
24 | - * | ||
25 | - * Intended to be used for partial clearing of a cache namespace. For a more | ||
26 | - * global "flushing", see {@see FlushableCache}. | ||
27 | - * | ||
28 | - * @link www.doctrine-project.org | ||
29 | - * @since 1.4 | ||
30 | - * @author Adirelle <adirelle@gmail.com> | ||
31 | - */ | ||
32 | -interface ClearableCache | ||
33 | -{ | ||
34 | - /** | ||
35 | - * Deletes all cache entries in the current cache namespace. | ||
36 | - * | ||
37 | - * @return boolean TRUE if the cache entries were successfully deleted, FALSE otherwise. | ||
38 | - */ | ||
39 | - public function deleteAll(); | ||
40 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -use \Couchbase; | ||
23 | - | ||
24 | -/** | ||
25 | - * Couchbase cache provider. | ||
26 | - * | ||
27 | - * @link www.doctrine-project.org | ||
28 | - * @since 2.4 | ||
29 | - * @author Michael Nitschinger <michael@nitschinger.at> | ||
30 | - */ | ||
31 | -class CouchbaseCache extends CacheProvider | ||
32 | -{ | ||
33 | - /** | ||
34 | - * @var Couchbase|null | ||
35 | - */ | ||
36 | - private $couchbase; | ||
37 | - | ||
38 | - /** | ||
39 | - * Sets the Couchbase instance to use. | ||
40 | - * | ||
41 | - * @param Couchbase $couchbase | ||
42 | - * | ||
43 | - * @return void | ||
44 | - */ | ||
45 | - public function setCouchbase(Couchbase $couchbase) | ||
46 | - { | ||
47 | - $this->couchbase = $couchbase; | ||
48 | - } | ||
49 | - | ||
50 | - /** | ||
51 | - * Gets the Couchbase instance used by the cache. | ||
52 | - * | ||
53 | - * @return Couchbase|null | ||
54 | - */ | ||
55 | - public function getCouchbase() | ||
56 | - { | ||
57 | - return $this->couchbase; | ||
58 | - } | ||
59 | - | ||
60 | - /** | ||
61 | - * {@inheritdoc} | ||
62 | - */ | ||
63 | - protected function doFetch($id) | ||
64 | - { | ||
65 | - return $this->couchbase->get($id) ?: false; | ||
66 | - } | ||
67 | - | ||
68 | - /** | ||
69 | - * {@inheritdoc} | ||
70 | - */ | ||
71 | - protected function doContains($id) | ||
72 | - { | ||
73 | - return (null !== $this->couchbase->get($id)); | ||
74 | - } | ||
75 | - | ||
76 | - /** | ||
77 | - * {@inheritdoc} | ||
78 | - */ | ||
79 | - protected function doSave($id, $data, $lifeTime = 0) | ||
80 | - { | ||
81 | - if ($lifeTime > 30 * 24 * 3600) { | ||
82 | - $lifeTime = time() + $lifeTime; | ||
83 | - } | ||
84 | - return $this->couchbase->set($id, $data, (int) $lifeTime); | ||
85 | - } | ||
86 | - | ||
87 | - /** | ||
88 | - * {@inheritdoc} | ||
89 | - */ | ||
90 | - protected function doDelete($id) | ||
91 | - { | ||
92 | - return $this->couchbase->delete($id); | ||
93 | - } | ||
94 | - | ||
95 | - /** | ||
96 | - * {@inheritdoc} | ||
97 | - */ | ||
98 | - protected function doFlush() | ||
99 | - { | ||
100 | - return $this->couchbase->flush(); | ||
101 | - } | ||
102 | - | ||
103 | - /** | ||
104 | - * {@inheritdoc} | ||
105 | - */ | ||
106 | - protected function doGetStats() | ||
107 | - { | ||
108 | - $stats = $this->couchbase->getStats(); | ||
109 | - $servers = $this->couchbase->getServers(); | ||
110 | - $server = explode(":", $servers[0]); | ||
111 | - $key = $server[0] . ":" . "11210"; | ||
112 | - $stats = $stats[$key]; | ||
113 | - return array( | ||
114 | - Cache::STATS_HITS => $stats['get_hits'], | ||
115 | - Cache::STATS_MISSES => $stats['get_misses'], | ||
116 | - Cache::STATS_UPTIME => $stats['uptime'], | ||
117 | - Cache::STATS_MEMORY_USAGE => $stats['bytes'], | ||
118 | - Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'], | ||
119 | - ); | ||
120 | - } | ||
121 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Base file cache driver. | ||
24 | - * | ||
25 | - * @since 2.3 | ||
26 | - * @author Fabio B. Silva <fabio.bat.silva@gmail.com> | ||
27 | - */ | ||
28 | -abstract class FileCache extends CacheProvider | ||
29 | -{ | ||
30 | - /** | ||
31 | - * The cache directory. | ||
32 | - * | ||
33 | - * @var string | ||
34 | - */ | ||
35 | - protected $directory; | ||
36 | - | ||
37 | - /** | ||
38 | - * The cache file extension. | ||
39 | - * | ||
40 | - * @var string | ||
41 | - */ | ||
42 | - private $extension; | ||
43 | - | ||
44 | - /** | ||
45 | - * @var string[] regular expressions for replacing disallowed characters in file name | ||
46 | - */ | ||
47 | - private $disallowedCharacterPatterns = array( | ||
48 | - '/\-/', // replaced to disambiguate original `-` and `-` derived from replacements | ||
49 | - '/[^a-zA-Z0-9\-_\[\]]/' // also excludes non-ascii chars (not supported, depending on FS) | ||
50 | - ); | ||
51 | - | ||
52 | - /** | ||
53 | - * @var string[] replacements for disallowed file characters | ||
54 | - */ | ||
55 | - private $replacementCharacters = array('__', '-'); | ||
56 | - | ||
57 | - /** | ||
58 | - * @var int | ||
59 | - */ | ||
60 | - private $umask; | ||
61 | - | ||
62 | - /** | ||
63 | - * Constructor. | ||
64 | - * | ||
65 | - * @param string $directory The cache directory. | ||
66 | - * @param string $extension The cache file extension. | ||
67 | - * | ||
68 | - * @throws \InvalidArgumentException | ||
69 | - */ | ||
70 | - public function __construct($directory, $extension = '', $umask = 0002) | ||
71 | - { | ||
72 | - // YES, this needs to be *before* createPathIfNeeded() | ||
73 | - if ( ! is_int($umask)) { | ||
74 | - throw new \InvalidArgumentException(sprintf( | ||
75 | - 'The umask parameter is required to be integer, was: %s', | ||
76 | - gettype($umask) | ||
77 | - )); | ||
78 | - } | ||
79 | - $this->umask = $umask; | ||
80 | - | ||
81 | - if ( ! $this->createPathIfNeeded($directory)) { | ||
82 | - throw new \InvalidArgumentException(sprintf( | ||
83 | - 'The directory "%s" does not exist and could not be created.', | ||
84 | - $directory | ||
85 | - )); | ||
86 | - } | ||
87 | - | ||
88 | - if ( ! is_writable($directory)) { | ||
89 | - throw new \InvalidArgumentException(sprintf( | ||
90 | - 'The directory "%s" is not writable.', | ||
91 | - $directory | ||
92 | - )); | ||
93 | - } | ||
94 | - | ||
95 | - // YES, this needs to be *after* createPathIfNeeded() | ||
96 | - $this->directory = realpath($directory); | ||
97 | - $this->extension = (string) $extension; | ||
98 | - } | ||
99 | - | ||
100 | - /** | ||
101 | - * Gets the cache directory. | ||
102 | - * | ||
103 | - * @return string | ||
104 | - */ | ||
105 | - public function getDirectory() | ||
106 | - { | ||
107 | - return $this->directory; | ||
108 | - } | ||
109 | - | ||
110 | - /** | ||
111 | - * Gets the cache file extension. | ||
112 | - * | ||
113 | - * @return string|null | ||
114 | - */ | ||
115 | - public function getExtension() | ||
116 | - { | ||
117 | - return $this->extension; | ||
118 | - } | ||
119 | - | ||
120 | - /** | ||
121 | - * @param string $id | ||
122 | - * | ||
123 | - * @return string | ||
124 | - */ | ||
125 | - protected function getFilename($id) | ||
126 | - { | ||
127 | - return $this->directory | ||
128 | - . DIRECTORY_SEPARATOR | ||
129 | - . implode(str_split(hash('sha256', $id), 2), DIRECTORY_SEPARATOR) | ||
130 | - . DIRECTORY_SEPARATOR | ||
131 | - . preg_replace($this->disallowedCharacterPatterns, $this->replacementCharacters, $id) | ||
132 | - . $this->extension; | ||
133 | - } | ||
134 | - | ||
135 | - /** | ||
136 | - * {@inheritdoc} | ||
137 | - */ | ||
138 | - protected function doDelete($id) | ||
139 | - { | ||
140 | - $filename = $this->getFilename($id); | ||
141 | - | ||
142 | - return @unlink($filename) || ! file_exists($filename); | ||
143 | - } | ||
144 | - | ||
145 | - /** | ||
146 | - * {@inheritdoc} | ||
147 | - */ | ||
148 | - protected function doFlush() | ||
149 | - { | ||
150 | - foreach ($this->getIterator() as $name => $file) { | ||
151 | - if ($file->isDir()) { | ||
152 | - // Remove the intermediate directories which have been created to balance the tree. It only takes effect | ||
153 | - // if the directory is empty. If several caches share the same directory but with different file extensions, | ||
154 | - // the other ones are not removed. | ||
155 | - @rmdir($name); | ||
156 | - } elseif ($this->isFilenameEndingWithExtension($name)) { | ||
157 | - // If an extension is set, only remove files which end with the given extension. | ||
158 | - // If no extension is set, we have no other choice than removing everything. | ||
159 | - @unlink($name); | ||
160 | - } | ||
161 | - } | ||
162 | - | ||
163 | - return true; | ||
164 | - } | ||
165 | - | ||
166 | - /** | ||
167 | - * {@inheritdoc} | ||
168 | - */ | ||
169 | - protected function doGetStats() | ||
170 | - { | ||
171 | - $usage = 0; | ||
172 | - foreach ($this->getIterator() as $name => $file) { | ||
173 | - if (! $file->isDir() && $this->isFilenameEndingWithExtension($name)) { | ||
174 | - $usage += $file->getSize(); | ||
175 | - } | ||
176 | - } | ||
177 | - | ||
178 | - $free = disk_free_space($this->directory); | ||
179 | - | ||
180 | - return array( | ||
181 | - Cache::STATS_HITS => null, | ||
182 | - Cache::STATS_MISSES => null, | ||
183 | - Cache::STATS_UPTIME => null, | ||
184 | - Cache::STATS_MEMORY_USAGE => $usage, | ||
185 | - Cache::STATS_MEMORY_AVAILABLE => $free, | ||
186 | - ); | ||
187 | - } | ||
188 | - | ||
189 | - /** | ||
190 | - * Create path if needed. | ||
191 | - * | ||
192 | - * @param string $path | ||
193 | - * @return bool TRUE on success or if path already exists, FALSE if path cannot be created. | ||
194 | - */ | ||
195 | - private function createPathIfNeeded($path) | ||
196 | - { | ||
197 | - if ( ! is_dir($path)) { | ||
198 | - if (false === @mkdir($path, 0777 & (~$this->umask), true) && !is_dir($path)) { | ||
199 | - return false; | ||
200 | - } | ||
201 | - } | ||
202 | - | ||
203 | - return true; | ||
204 | - } | ||
205 | - | ||
206 | - /** | ||
207 | - * Writes a string content to file in an atomic way. | ||
208 | - * | ||
209 | - * @param string $filename Path to the file where to write the data. | ||
210 | - * @param string $content The content to write | ||
211 | - * | ||
212 | - * @return bool TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error. | ||
213 | - */ | ||
214 | - protected function writeFile($filename, $content) | ||
215 | - { | ||
216 | - $filepath = pathinfo($filename, PATHINFO_DIRNAME); | ||
217 | - | ||
218 | - if ( ! $this->createPathIfNeeded($filepath)) { | ||
219 | - return false; | ||
220 | - } | ||
221 | - | ||
222 | - if ( ! is_writable($filepath)) { | ||
223 | - return false; | ||
224 | - } | ||
225 | - | ||
226 | - $tmpFile = tempnam($filepath, 'swap'); | ||
227 | - @chmod($tmpFile, 0666 & (~$this->umask)); | ||
228 | - | ||
229 | - if (file_put_contents($tmpFile, $content) !== false) { | ||
230 | - if (@rename($tmpFile, $filename)) { | ||
231 | - return true; | ||
232 | - } | ||
233 | - | ||
234 | - @unlink($tmpFile); | ||
235 | - } | ||
236 | - | ||
237 | - return false; | ||
238 | - } | ||
239 | - | ||
240 | - /** | ||
241 | - * @return \Iterator | ||
242 | - */ | ||
243 | - private function getIterator() | ||
244 | - { | ||
245 | - return new \RecursiveIteratorIterator( | ||
246 | - new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS), | ||
247 | - \RecursiveIteratorIterator::CHILD_FIRST | ||
248 | - ); | ||
249 | - } | ||
250 | - | ||
251 | - /** | ||
252 | - * @param string $name The filename | ||
253 | - * | ||
254 | - * @return bool | ||
255 | - */ | ||
256 | - private function isFilenameEndingWithExtension($name) | ||
257 | - { | ||
258 | - return '' === $this->extension | ||
259 | - || strrpos($name, $this->extension) === (strlen($name) - strlen($this->extension)); | ||
260 | - } | ||
261 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Filesystem cache driver. | ||
24 | - * | ||
25 | - * @since 2.3 | ||
26 | - * @author Fabio B. Silva <fabio.bat.silva@gmail.com> | ||
27 | - */ | ||
28 | -class FilesystemCache extends FileCache | ||
29 | -{ | ||
30 | - const EXTENSION = '.doctrinecache.data'; | ||
31 | - | ||
32 | - /** | ||
33 | - * {@inheritdoc} | ||
34 | - */ | ||
35 | - public function __construct($directory, $extension = self::EXTENSION, $umask = 0002) | ||
36 | - { | ||
37 | - parent::__construct($directory, $extension, $umask); | ||
38 | - } | ||
39 | - | ||
40 | - /** | ||
41 | - * {@inheritdoc} | ||
42 | - */ | ||
43 | - protected function doFetch($id) | ||
44 | - { | ||
45 | - $data = ''; | ||
46 | - $lifetime = -1; | ||
47 | - $filename = $this->getFilename($id); | ||
48 | - | ||
49 | - if ( ! is_file($filename)) { | ||
50 | - return false; | ||
51 | - } | ||
52 | - | ||
53 | - $resource = fopen($filename, "r"); | ||
54 | - | ||
55 | - if (false !== ($line = fgets($resource))) { | ||
56 | - $lifetime = (int) $line; | ||
57 | - } | ||
58 | - | ||
59 | - if ($lifetime !== 0 && $lifetime < time()) { | ||
60 | - fclose($resource); | ||
61 | - | ||
62 | - return false; | ||
63 | - } | ||
64 | - | ||
65 | - while (false !== ($line = fgets($resource))) { | ||
66 | - $data .= $line; | ||
67 | - } | ||
68 | - | ||
69 | - fclose($resource); | ||
70 | - | ||
71 | - return unserialize($data); | ||
72 | - } | ||
73 | - | ||
74 | - /** | ||
75 | - * {@inheritdoc} | ||
76 | - */ | ||
77 | - protected function doContains($id) | ||
78 | - { | ||
79 | - $lifetime = -1; | ||
80 | - $filename = $this->getFilename($id); | ||
81 | - | ||
82 | - if ( ! is_file($filename)) { | ||
83 | - return false; | ||
84 | - } | ||
85 | - | ||
86 | - $resource = fopen($filename, "r"); | ||
87 | - | ||
88 | - if (false !== ($line = fgets($resource))) { | ||
89 | - $lifetime = (int) $line; | ||
90 | - } | ||
91 | - | ||
92 | - fclose($resource); | ||
93 | - | ||
94 | - return $lifetime === 0 || $lifetime > time(); | ||
95 | - } | ||
96 | - | ||
97 | - /** | ||
98 | - * {@inheritdoc} | ||
99 | - */ | ||
100 | - protected function doSave($id, $data, $lifeTime = 0) | ||
101 | - { | ||
102 | - if ($lifeTime > 0) { | ||
103 | - $lifeTime = time() + $lifeTime; | ||
104 | - } | ||
105 | - | ||
106 | - $data = serialize($data); | ||
107 | - $filename = $this->getFilename($id); | ||
108 | - | ||
109 | - return $this->writeFile($filename, $lifeTime . PHP_EOL . $data); | ||
110 | - } | ||
111 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Interface for cache that can be flushed. | ||
24 | - * | ||
25 | - * @link www.doctrine-project.org | ||
26 | - * @since 1.4 | ||
27 | - * @author Adirelle <adirelle@gmail.com> | ||
28 | - */ | ||
29 | -interface FlushableCache | ||
30 | -{ | ||
31 | - /** | ||
32 | - * Flushes all cache entries, globally. | ||
33 | - * | ||
34 | - * @return boolean TRUE if the cache entries were successfully flushed, FALSE otherwise. | ||
35 | - */ | ||
36 | - public function flushAll(); | ||
37 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -use \Memcache; | ||
23 | - | ||
24 | -/** | ||
25 | - * Memcache cache provider. | ||
26 | - * | ||
27 | - * @link www.doctrine-project.org | ||
28 | - * @since 2.0 | ||
29 | - * @author Benjamin Eberlei <kontakt@beberlei.de> | ||
30 | - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
31 | - * @author Jonathan Wage <jonwage@gmail.com> | ||
32 | - * @author Roman Borschel <roman@code-factory.org> | ||
33 | - * @author David Abdemoulaie <dave@hobodave.com> | ||
34 | - */ | ||
35 | -class MemcacheCache extends CacheProvider | ||
36 | -{ | ||
37 | - /** | ||
38 | - * @var Memcache|null | ||
39 | - */ | ||
40 | - private $memcache; | ||
41 | - | ||
42 | - /** | ||
43 | - * Sets the memcache instance to use. | ||
44 | - * | ||
45 | - * @param Memcache $memcache | ||
46 | - * | ||
47 | - * @return void | ||
48 | - */ | ||
49 | - public function setMemcache(Memcache $memcache) | ||
50 | - { | ||
51 | - $this->memcache = $memcache; | ||
52 | - } | ||
53 | - | ||
54 | - /** | ||
55 | - * Gets the memcache instance used by the cache. | ||
56 | - * | ||
57 | - * @return Memcache|null | ||
58 | - */ | ||
59 | - public function getMemcache() | ||
60 | - { | ||
61 | - return $this->memcache; | ||
62 | - } | ||
63 | - | ||
64 | - /** | ||
65 | - * {@inheritdoc} | ||
66 | - */ | ||
67 | - protected function doFetch($id) | ||
68 | - { | ||
69 | - return $this->memcache->get($id); | ||
70 | - } | ||
71 | - | ||
72 | - /** | ||
73 | - * {@inheritdoc} | ||
74 | - */ | ||
75 | - protected function doContains($id) | ||
76 | - { | ||
77 | - $flags = null; | ||
78 | - $this->memcache->get($id, $flags); | ||
79 | - | ||
80 | - //if memcache has changed the value of "flags", it means the value exists | ||
81 | - return ($flags !== null); | ||
82 | - } | ||
83 | - | ||
84 | - /** | ||
85 | - * {@inheritdoc} | ||
86 | - */ | ||
87 | - protected function doSave($id, $data, $lifeTime = 0) | ||
88 | - { | ||
89 | - if ($lifeTime > 30 * 24 * 3600) { | ||
90 | - $lifeTime = time() + $lifeTime; | ||
91 | - } | ||
92 | - return $this->memcache->set($id, $data, 0, (int) $lifeTime); | ||
93 | - } | ||
94 | - | ||
95 | - /** | ||
96 | - * {@inheritdoc} | ||
97 | - */ | ||
98 | - protected function doDelete($id) | ||
99 | - { | ||
100 | - // Memcache::delete() returns false if entry does not exist | ||
101 | - return $this->memcache->delete($id) || ! $this->doContains($id); | ||
102 | - } | ||
103 | - | ||
104 | - /** | ||
105 | - * {@inheritdoc} | ||
106 | - */ | ||
107 | - protected function doFlush() | ||
108 | - { | ||
109 | - return $this->memcache->flush(); | ||
110 | - } | ||
111 | - | ||
112 | - /** | ||
113 | - * {@inheritdoc} | ||
114 | - */ | ||
115 | - protected function doGetStats() | ||
116 | - { | ||
117 | - $stats = $this->memcache->getStats(); | ||
118 | - return array( | ||
119 | - Cache::STATS_HITS => $stats['get_hits'], | ||
120 | - Cache::STATS_MISSES => $stats['get_misses'], | ||
121 | - Cache::STATS_UPTIME => $stats['uptime'], | ||
122 | - Cache::STATS_MEMORY_USAGE => $stats['bytes'], | ||
123 | - Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'], | ||
124 | - ); | ||
125 | - } | ||
126 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -use \Memcached; | ||
23 | - | ||
24 | -/** | ||
25 | - * Memcached cache provider. | ||
26 | - * | ||
27 | - * @link www.doctrine-project.org | ||
28 | - * @since 2.2 | ||
29 | - * @author Benjamin Eberlei <kontakt@beberlei.de> | ||
30 | - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
31 | - * @author Jonathan Wage <jonwage@gmail.com> | ||
32 | - * @author Roman Borschel <roman@code-factory.org> | ||
33 | - * @author David Abdemoulaie <dave@hobodave.com> | ||
34 | - */ | ||
35 | -class MemcachedCache extends CacheProvider | ||
36 | -{ | ||
37 | - /** | ||
38 | - * @var Memcached|null | ||
39 | - */ | ||
40 | - private $memcached; | ||
41 | - | ||
42 | - /** | ||
43 | - * Sets the memcache instance to use. | ||
44 | - * | ||
45 | - * @param Memcached $memcached | ||
46 | - * | ||
47 | - * @return void | ||
48 | - */ | ||
49 | - public function setMemcached(Memcached $memcached) | ||
50 | - { | ||
51 | - $this->memcached = $memcached; | ||
52 | - } | ||
53 | - | ||
54 | - /** | ||
55 | - * Gets the memcached instance used by the cache. | ||
56 | - * | ||
57 | - * @return Memcached|null | ||
58 | - */ | ||
59 | - public function getMemcached() | ||
60 | - { | ||
61 | - return $this->memcached; | ||
62 | - } | ||
63 | - | ||
64 | - /** | ||
65 | - * {@inheritdoc} | ||
66 | - */ | ||
67 | - protected function doFetch($id) | ||
68 | - { | ||
69 | - return $this->memcached->get($id); | ||
70 | - } | ||
71 | - | ||
72 | - /** | ||
73 | - * {@inheritdoc} | ||
74 | - */ | ||
75 | - protected function doFetchMultiple(array $keys) | ||
76 | - { | ||
77 | - return $this->memcached->getMulti($keys); | ||
78 | - } | ||
79 | - | ||
80 | - /** | ||
81 | - * {@inheritdoc} | ||
82 | - */ | ||
83 | - protected function doContains($id) | ||
84 | - { | ||
85 | - return false !== $this->memcached->get($id) | ||
86 | - || $this->memcached->getResultCode() !== Memcached::RES_NOTFOUND; | ||
87 | - } | ||
88 | - | ||
89 | - /** | ||
90 | - * {@inheritdoc} | ||
91 | - */ | ||
92 | - protected function doSave($id, $data, $lifeTime = 0) | ||
93 | - { | ||
94 | - if ($lifeTime > 30 * 24 * 3600) { | ||
95 | - $lifeTime = time() + $lifeTime; | ||
96 | - } | ||
97 | - return $this->memcached->set($id, $data, (int) $lifeTime); | ||
98 | - } | ||
99 | - | ||
100 | - /** | ||
101 | - * {@inheritdoc} | ||
102 | - */ | ||
103 | - protected function doDelete($id) | ||
104 | - { | ||
105 | - return $this->memcached->delete($id) | ||
106 | - || $this->memcached->getResultCode() === Memcached::RES_NOTFOUND; | ||
107 | - } | ||
108 | - | ||
109 | - /** | ||
110 | - * {@inheritdoc} | ||
111 | - */ | ||
112 | - protected function doFlush() | ||
113 | - { | ||
114 | - return $this->memcached->flush(); | ||
115 | - } | ||
116 | - | ||
117 | - /** | ||
118 | - * {@inheritdoc} | ||
119 | - */ | ||
120 | - protected function doGetStats() | ||
121 | - { | ||
122 | - $stats = $this->memcached->getStats(); | ||
123 | - $servers = $this->memcached->getServerList(); | ||
124 | - $key = $servers[0]['host'] . ':' . $servers[0]['port']; | ||
125 | - $stats = $stats[$key]; | ||
126 | - return array( | ||
127 | - Cache::STATS_HITS => $stats['get_hits'], | ||
128 | - Cache::STATS_MISSES => $stats['get_misses'], | ||
129 | - Cache::STATS_UPTIME => $stats['uptime'], | ||
130 | - Cache::STATS_MEMORY_USAGE => $stats['bytes'], | ||
131 | - Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'], | ||
132 | - ); | ||
133 | - } | ||
134 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -use MongoBinData; | ||
23 | -use MongoCollection; | ||
24 | -use MongoDate; | ||
25 | - | ||
26 | -/** | ||
27 | - * MongoDB cache provider. | ||
28 | - * | ||
29 | - * @since 1.1 | ||
30 | - * @author Jeremy Mikola <jmikola@gmail.com> | ||
31 | - */ | ||
32 | -class MongoDBCache extends CacheProvider | ||
33 | -{ | ||
34 | - /** | ||
35 | - * The data field will store the serialized PHP value. | ||
36 | - */ | ||
37 | - const DATA_FIELD = 'd'; | ||
38 | - | ||
39 | - /** | ||
40 | - * The expiration field will store a MongoDate value indicating when the | ||
41 | - * cache entry should expire. | ||
42 | - * | ||
43 | - * With MongoDB 2.2+, entries can be automatically deleted by MongoDB by | ||
44 | - * indexing this field with the "expireAfterSeconds" option equal to zero. | ||
45 | - * This will direct MongoDB to regularly query for and delete any entries | ||
46 | - * whose date is older than the current time. Entries without a date value | ||
47 | - * in this field will be ignored. | ||
48 | - * | ||
49 | - * The cache provider will also check dates on its own, in case expired | ||
50 | - * entries are fetched before MongoDB's TTLMonitor pass can expire them. | ||
51 | - * | ||
52 | - * @see http://docs.mongodb.org/manual/tutorial/expire-data/ | ||
53 | - */ | ||
54 | - const EXPIRATION_FIELD = 'e'; | ||
55 | - | ||
56 | - /** | ||
57 | - * @var MongoCollection | ||
58 | - */ | ||
59 | - private $collection; | ||
60 | - | ||
61 | - /** | ||
62 | - * Constructor. | ||
63 | - * | ||
64 | - * This provider will default to the write concern and read preference | ||
65 | - * options set on the MongoCollection instance (or inherited from MongoDB or | ||
66 | - * MongoClient). Using an unacknowledged write concern (< 1) may make the | ||
67 | - * return values of delete() and save() unreliable. Reading from secondaries | ||
68 | - * may make contain() and fetch() unreliable. | ||
69 | - * | ||
70 | - * @see http://www.php.net/manual/en/mongo.readpreferences.php | ||
71 | - * @see http://www.php.net/manual/en/mongo.writeconcerns.php | ||
72 | - * @param MongoCollection $collection | ||
73 | - */ | ||
74 | - public function __construct(MongoCollection $collection) | ||
75 | - { | ||
76 | - $this->collection = $collection; | ||
77 | - } | ||
78 | - | ||
79 | - /** | ||
80 | - * {@inheritdoc} | ||
81 | - */ | ||
82 | - protected function doFetch($id) | ||
83 | - { | ||
84 | - $document = $this->collection->findOne(array('_id' => $id), array(self::DATA_FIELD, self::EXPIRATION_FIELD)); | ||
85 | - | ||
86 | - if ($document === null) { | ||
87 | - return false; | ||
88 | - } | ||
89 | - | ||
90 | - if ($this->isExpired($document)) { | ||
91 | - $this->doDelete($id); | ||
92 | - return false; | ||
93 | - } | ||
94 | - | ||
95 | - return unserialize($document[self::DATA_FIELD]->bin); | ||
96 | - } | ||
97 | - | ||
98 | - /** | ||
99 | - * {@inheritdoc} | ||
100 | - */ | ||
101 | - protected function doContains($id) | ||
102 | - { | ||
103 | - $document = $this->collection->findOne(array('_id' => $id), array(self::EXPIRATION_FIELD)); | ||
104 | - | ||
105 | - if ($document === null) { | ||
106 | - return false; | ||
107 | - } | ||
108 | - | ||
109 | - if ($this->isExpired($document)) { | ||
110 | - $this->doDelete($id); | ||
111 | - return false; | ||
112 | - } | ||
113 | - | ||
114 | - return true; | ||
115 | - } | ||
116 | - | ||
117 | - /** | ||
118 | - * {@inheritdoc} | ||
119 | - */ | ||
120 | - protected function doSave($id, $data, $lifeTime = 0) | ||
121 | - { | ||
122 | - $result = $this->collection->update( | ||
123 | - array('_id' => $id), | ||
124 | - array('$set' => array( | ||
125 | - self::EXPIRATION_FIELD => ($lifeTime > 0 ? new MongoDate(time() + $lifeTime) : null), | ||
126 | - self::DATA_FIELD => new MongoBinData(serialize($data), MongoBinData::BYTE_ARRAY), | ||
127 | - )), | ||
128 | - array('upsert' => true, 'multiple' => false) | ||
129 | - ); | ||
130 | - | ||
131 | - return isset($result['ok']) ? $result['ok'] == 1 : true; | ||
132 | - } | ||
133 | - | ||
134 | - /** | ||
135 | - * {@inheritdoc} | ||
136 | - */ | ||
137 | - protected function doDelete($id) | ||
138 | - { | ||
139 | - $result = $this->collection->remove(array('_id' => $id)); | ||
140 | - | ||
141 | - return isset($result['ok']) ? $result['ok'] == 1 : true; | ||
142 | - } | ||
143 | - | ||
144 | - /** | ||
145 | - * {@inheritdoc} | ||
146 | - */ | ||
147 | - protected function doFlush() | ||
148 | - { | ||
149 | - // Use remove() in lieu of drop() to maintain any collection indexes | ||
150 | - $result = $this->collection->remove(); | ||
151 | - | ||
152 | - return isset($result['ok']) ? $result['ok'] == 1 : true; | ||
153 | - } | ||
154 | - | ||
155 | - /** | ||
156 | - * {@inheritdoc} | ||
157 | - */ | ||
158 | - protected function doGetStats() | ||
159 | - { | ||
160 | - $serverStatus = $this->collection->db->command(array( | ||
161 | - 'serverStatus' => 1, | ||
162 | - 'locks' => 0, | ||
163 | - 'metrics' => 0, | ||
164 | - 'recordStats' => 0, | ||
165 | - 'repl' => 0, | ||
166 | - )); | ||
167 | - | ||
168 | - $collStats = $this->collection->db->command(array('collStats' => 1)); | ||
169 | - | ||
170 | - return array( | ||
171 | - Cache::STATS_HITS => null, | ||
172 | - Cache::STATS_MISSES => null, | ||
173 | - Cache::STATS_UPTIME => (isset($serverStatus['uptime']) ? (int) $serverStatus['uptime'] : null), | ||
174 | - Cache::STATS_MEMORY_USAGE => (isset($collStats['size']) ? (int) $collStats['size'] : null), | ||
175 | - Cache::STATS_MEMORY_AVAILABLE => null, | ||
176 | - ); | ||
177 | - } | ||
178 | - | ||
179 | - /** | ||
180 | - * Check if the document is expired. | ||
181 | - * | ||
182 | - * @param array $document | ||
183 | - * @return boolean | ||
184 | - */ | ||
185 | - private function isExpired(array $document) | ||
186 | - { | ||
187 | - return isset($document[self::EXPIRATION_FIELD]) && | ||
188 | - $document[self::EXPIRATION_FIELD] instanceof MongoDate && | ||
189 | - $document[self::EXPIRATION_FIELD]->sec < time(); | ||
190 | - } | ||
191 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Interface for cache drivers that allows to get many items at once. | ||
24 | - * | ||
25 | - * @link www.doctrine-project.org | ||
26 | - * @since 1.4 | ||
27 | - * @author Asmir Mustafic <goetas@gmail.com> | ||
28 | - */ | ||
29 | -interface MultiGetCache | ||
30 | -{ | ||
31 | - /** | ||
32 | - * Returns an associative array of values for keys is found in cache. | ||
33 | - * | ||
34 | - * @param string[] $keys Array of keys to retrieve from cache | ||
35 | - * @return mixed[] Array of retrieved values, indexed by the specified keys. | ||
36 | - * Values that couldn't be retrieved are not contained in this array. | ||
37 | - */ | ||
38 | - function fetchMultiple(array $keys); | ||
39 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Php file cache driver. | ||
24 | - * | ||
25 | - * @since 2.3 | ||
26 | - * @author Fabio B. Silva <fabio.bat.silva@gmail.com> | ||
27 | - */ | ||
28 | -class PhpFileCache extends FileCache | ||
29 | -{ | ||
30 | - const EXTENSION = '.doctrinecache.php'; | ||
31 | - | ||
32 | - /** | ||
33 | - * {@inheritdoc} | ||
34 | - */ | ||
35 | - public function __construct($directory, $extension = self::EXTENSION, $umask = 0002) | ||
36 | - { | ||
37 | - parent::__construct($directory, $extension, $umask); | ||
38 | - } | ||
39 | - | ||
40 | - /** | ||
41 | - * {@inheritdoc} | ||
42 | - */ | ||
43 | - protected function doFetch($id) | ||
44 | - { | ||
45 | - $value = $this->includeFileForId($id); | ||
46 | - | ||
47 | - if (! $value) { | ||
48 | - return false; | ||
49 | - } | ||
50 | - | ||
51 | - if ($value['lifetime'] !== 0 && $value['lifetime'] < time()) { | ||
52 | - return false; | ||
53 | - } | ||
54 | - | ||
55 | - return $value['data']; | ||
56 | - } | ||
57 | - | ||
58 | - /** | ||
59 | - * {@inheritdoc} | ||
60 | - */ | ||
61 | - protected function doContains($id) | ||
62 | - { | ||
63 | - $value = $this->includeFileForId($id); | ||
64 | - | ||
65 | - if (! $value) { | ||
66 | - return false; | ||
67 | - } | ||
68 | - | ||
69 | - return $value['lifetime'] === 0 || $value['lifetime'] > time(); | ||
70 | - } | ||
71 | - | ||
72 | - /** | ||
73 | - * {@inheritdoc} | ||
74 | - */ | ||
75 | - protected function doSave($id, $data, $lifeTime = 0) | ||
76 | - { | ||
77 | - if ($lifeTime > 0) { | ||
78 | - $lifeTime = time() + $lifeTime; | ||
79 | - } | ||
80 | - | ||
81 | - if (is_object($data) && ! method_exists($data, '__set_state')) { | ||
82 | - throw new \InvalidArgumentException( | ||
83 | - "Invalid argument given, PhpFileCache only allows objects that implement __set_state() " . | ||
84 | - "and fully support var_export(). You can use the FilesystemCache to save arbitrary object " . | ||
85 | - "graphs using serialize()/deserialize()." | ||
86 | - ); | ||
87 | - } | ||
88 | - | ||
89 | - $filename = $this->getFilename($id); | ||
90 | - | ||
91 | - $value = array( | ||
92 | - 'lifetime' => $lifeTime, | ||
93 | - 'data' => $data | ||
94 | - ); | ||
95 | - | ||
96 | - $value = var_export($value, true); | ||
97 | - $code = sprintf('<?php return %s;', $value); | ||
98 | - | ||
99 | - return $this->writeFile($filename, $code); | ||
100 | - } | ||
101 | - | ||
102 | - /** | ||
103 | - * @param string $id | ||
104 | - * | ||
105 | - * @return array|false | ||
106 | - */ | ||
107 | - private function includeFileForId($id) | ||
108 | - { | ||
109 | - $fileName = $this->getFilename($id); | ||
110 | - | ||
111 | - // note: error suppression is still faster than `file_exists`, `is_file` and `is_readable` | ||
112 | - $value = @include $fileName; | ||
113 | - | ||
114 | - if (! isset($value['lifetime'])) { | ||
115 | - return false; | ||
116 | - } | ||
117 | - | ||
118 | - return $value; | ||
119 | - } | ||
120 | -} |
1 | -<?php | ||
2 | - | ||
3 | -namespace Doctrine\Common\Cache; | ||
4 | - | ||
5 | -use Predis\Client; | ||
6 | - | ||
7 | -/** | ||
8 | - * Predis cache provider. | ||
9 | - * | ||
10 | - * @author othillo <othillo@othillo.nl> | ||
11 | - */ | ||
12 | -class PredisCache extends CacheProvider | ||
13 | -{ | ||
14 | - /** | ||
15 | - * @var Client | ||
16 | - */ | ||
17 | - private $client; | ||
18 | - | ||
19 | - /** | ||
20 | - * @param Client $client | ||
21 | - * | ||
22 | - * @return void | ||
23 | - */ | ||
24 | - public function __construct(Client $client) | ||
25 | - { | ||
26 | - $this->client = $client; | ||
27 | - } | ||
28 | - | ||
29 | - /** | ||
30 | - * {@inheritdoc} | ||
31 | - */ | ||
32 | - protected function doFetch($id) | ||
33 | - { | ||
34 | - $result = $this->client->get($id); | ||
35 | - if (null === $result) { | ||
36 | - return false; | ||
37 | - } | ||
38 | - | ||
39 | - return unserialize($result); | ||
40 | - } | ||
41 | - | ||
42 | - /** | ||
43 | - * {@inheritdoc} | ||
44 | - */ | ||
45 | - protected function doFetchMultiple(array $keys) | ||
46 | - { | ||
47 | - $fetchedItems = call_user_func_array(array($this->client, 'mget'), $keys); | ||
48 | - | ||
49 | - return array_map('unserialize', array_filter(array_combine($keys, $fetchedItems))); | ||
50 | - } | ||
51 | - | ||
52 | - /** | ||
53 | - * {@inheritdoc} | ||
54 | - */ | ||
55 | - protected function doContains($id) | ||
56 | - { | ||
57 | - return $this->client->exists($id); | ||
58 | - } | ||
59 | - | ||
60 | - /** | ||
61 | - * {@inheritdoc} | ||
62 | - */ | ||
63 | - protected function doSave($id, $data, $lifeTime = 0) | ||
64 | - { | ||
65 | - $data = serialize($data); | ||
66 | - if ($lifeTime > 0) { | ||
67 | - $response = $this->client->setex($id, $lifeTime, $data); | ||
68 | - } else { | ||
69 | - $response = $this->client->set($id, $data); | ||
70 | - } | ||
71 | - | ||
72 | - return $response === true || $response == 'OK'; | ||
73 | - } | ||
74 | - | ||
75 | - /** | ||
76 | - * {@inheritdoc} | ||
77 | - */ | ||
78 | - protected function doDelete($id) | ||
79 | - { | ||
80 | - return $this->client->del($id) >= 0; | ||
81 | - } | ||
82 | - | ||
83 | - /** | ||
84 | - * {@inheritdoc} | ||
85 | - */ | ||
86 | - protected function doFlush() | ||
87 | - { | ||
88 | - $response = $this->client->flushdb(); | ||
89 | - | ||
90 | - return $response === true || $response == 'OK'; | ||
91 | - } | ||
92 | - | ||
93 | - /** | ||
94 | - * {@inheritdoc} | ||
95 | - */ | ||
96 | - protected function doGetStats() | ||
97 | - { | ||
98 | - $info = $this->client->info(); | ||
99 | - | ||
100 | - return array( | ||
101 | - Cache::STATS_HITS => $info['Stats']['keyspace_hits'], | ||
102 | - Cache::STATS_MISSES => $info['Stats']['keyspace_misses'], | ||
103 | - Cache::STATS_UPTIME => $info['Server']['uptime_in_seconds'], | ||
104 | - Cache::STATS_MEMORY_USAGE => $info['Memory']['used_memory'], | ||
105 | - Cache::STATS_MEMORY_AVAILABLE => false | ||
106 | - ); | ||
107 | - } | ||
108 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -use Redis; | ||
23 | - | ||
24 | -/** | ||
25 | - * Redis cache provider. | ||
26 | - * | ||
27 | - * @link www.doctrine-project.org | ||
28 | - * @since 2.2 | ||
29 | - * @author Osman Ungur <osmanungur@gmail.com> | ||
30 | - */ | ||
31 | -class RedisCache extends CacheProvider | ||
32 | -{ | ||
33 | - /** | ||
34 | - * @var Redis|null | ||
35 | - */ | ||
36 | - private $redis; | ||
37 | - | ||
38 | - /** | ||
39 | - * Sets the redis instance to use. | ||
40 | - * | ||
41 | - * @param Redis $redis | ||
42 | - * | ||
43 | - * @return void | ||
44 | - */ | ||
45 | - public function setRedis(Redis $redis) | ||
46 | - { | ||
47 | - $redis->setOption(Redis::OPT_SERIALIZER, $this->getSerializerValue()); | ||
48 | - $this->redis = $redis; | ||
49 | - } | ||
50 | - | ||
51 | - /** | ||
52 | - * Gets the redis instance used by the cache. | ||
53 | - * | ||
54 | - * @return Redis|null | ||
55 | - */ | ||
56 | - public function getRedis() | ||
57 | - { | ||
58 | - return $this->redis; | ||
59 | - } | ||
60 | - | ||
61 | - /** | ||
62 | - * {@inheritdoc} | ||
63 | - */ | ||
64 | - protected function doFetch($id) | ||
65 | - { | ||
66 | - return $this->redis->get($id); | ||
67 | - } | ||
68 | - | ||
69 | - /** | ||
70 | - * {@inheritdoc} | ||
71 | - */ | ||
72 | - protected function doFetchMultiple(array $keys) | ||
73 | - { | ||
74 | - $fetchedItems = $this->redis->mget($keys); | ||
75 | - | ||
76 | - return array_filter( | ||
77 | - array_combine($keys, $fetchedItems), | ||
78 | - function ($value) { | ||
79 | - return $value !== false; | ||
80 | - } | ||
81 | - ); | ||
82 | - } | ||
83 | - | ||
84 | - /** | ||
85 | - * {@inheritdoc} | ||
86 | - */ | ||
87 | - protected function doContains($id) | ||
88 | - { | ||
89 | - return $this->redis->exists($id); | ||
90 | - } | ||
91 | - | ||
92 | - /** | ||
93 | - * {@inheritdoc} | ||
94 | - */ | ||
95 | - protected function doSave($id, $data, $lifeTime = 0) | ||
96 | - { | ||
97 | - if ($lifeTime > 0) { | ||
98 | - return $this->redis->setex($id, $lifeTime, $data); | ||
99 | - } | ||
100 | - | ||
101 | - return $this->redis->set($id, $data); | ||
102 | - } | ||
103 | - | ||
104 | - /** | ||
105 | - * {@inheritdoc} | ||
106 | - */ | ||
107 | - protected function doDelete($id) | ||
108 | - { | ||
109 | - return $this->redis->delete($id) >= 0; | ||
110 | - } | ||
111 | - | ||
112 | - /** | ||
113 | - * {@inheritdoc} | ||
114 | - */ | ||
115 | - protected function doFlush() | ||
116 | - { | ||
117 | - return $this->redis->flushDB(); | ||
118 | - } | ||
119 | - | ||
120 | - /** | ||
121 | - * {@inheritdoc} | ||
122 | - */ | ||
123 | - protected function doGetStats() | ||
124 | - { | ||
125 | - $info = $this->redis->info(); | ||
126 | - return array( | ||
127 | - Cache::STATS_HITS => $info['keyspace_hits'], | ||
128 | - Cache::STATS_MISSES => $info['keyspace_misses'], | ||
129 | - Cache::STATS_UPTIME => $info['uptime_in_seconds'], | ||
130 | - Cache::STATS_MEMORY_USAGE => $info['used_memory'], | ||
131 | - Cache::STATS_MEMORY_AVAILABLE => false | ||
132 | - ); | ||
133 | - } | ||
134 | - | ||
135 | - /** | ||
136 | - * Returns the serializer constant to use. If Redis is compiled with | ||
137 | - * igbinary support, that is used. Otherwise the default PHP serializer is | ||
138 | - * used. | ||
139 | - * | ||
140 | - * @return integer One of the Redis::SERIALIZER_* constants | ||
141 | - */ | ||
142 | - protected function getSerializerValue() | ||
143 | - { | ||
144 | - if (defined('HHVM_VERSION')) { | ||
145 | - return Redis::SERIALIZER_PHP; | ||
146 | - } | ||
147 | - return defined('Redis::SERIALIZER_IGBINARY') ? Redis::SERIALIZER_IGBINARY : Redis::SERIALIZER_PHP; | ||
148 | - } | ||
149 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -use Riak\Bucket; | ||
23 | -use Riak\Connection; | ||
24 | -use Riak\Input; | ||
25 | -use Riak\Exception; | ||
26 | -use Riak\Object; | ||
27 | - | ||
28 | -/** | ||
29 | - * Riak cache provider. | ||
30 | - * | ||
31 | - * @link www.doctrine-project.org | ||
32 | - * @since 1.1 | ||
33 | - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
34 | - */ | ||
35 | -class RiakCache extends CacheProvider | ||
36 | -{ | ||
37 | - const EXPIRES_HEADER = 'X-Riak-Meta-Expires'; | ||
38 | - | ||
39 | - /** | ||
40 | - * @var \Riak\Bucket | ||
41 | - */ | ||
42 | - private $bucket; | ||
43 | - | ||
44 | - /** | ||
45 | - * Sets the riak bucket instance to use. | ||
46 | - * | ||
47 | - * @param \Riak\Bucket $bucket | ||
48 | - */ | ||
49 | - public function __construct(Bucket $bucket) | ||
50 | - { | ||
51 | - $this->bucket = $bucket; | ||
52 | - } | ||
53 | - | ||
54 | - /** | ||
55 | - * {@inheritdoc} | ||
56 | - */ | ||
57 | - protected function doFetch($id) | ||
58 | - { | ||
59 | - try { | ||
60 | - $response = $this->bucket->get($id); | ||
61 | - | ||
62 | - // No objects found | ||
63 | - if ( ! $response->hasObject()) { | ||
64 | - return false; | ||
65 | - } | ||
66 | - | ||
67 | - // Check for attempted siblings | ||
68 | - $object = ($response->hasSiblings()) | ||
69 | - ? $this->resolveConflict($id, $response->getVClock(), $response->getObjectList()) | ||
70 | - : $response->getFirstObject(); | ||
71 | - | ||
72 | - // Check for expired object | ||
73 | - if ($this->isExpired($object)) { | ||
74 | - $this->bucket->delete($object); | ||
75 | - | ||
76 | - return false; | ||
77 | - } | ||
78 | - | ||
79 | - return unserialize($object->getContent()); | ||
80 | - } catch (Exception\RiakException $e) { | ||
81 | - // Covers: | ||
82 | - // - Riak\ConnectionException | ||
83 | - // - Riak\CommunicationException | ||
84 | - // - Riak\UnexpectedResponseException | ||
85 | - // - Riak\NotFoundException | ||
86 | - } | ||
87 | - | ||
88 | - return false; | ||
89 | - } | ||
90 | - | ||
91 | - /** | ||
92 | - * {@inheritdoc} | ||
93 | - */ | ||
94 | - protected function doContains($id) | ||
95 | - { | ||
96 | - try { | ||
97 | - // We only need the HEAD, not the entire object | ||
98 | - $input = new Input\GetInput(); | ||
99 | - | ||
100 | - $input->setReturnHead(true); | ||
101 | - | ||
102 | - $response = $this->bucket->get($id, $input); | ||
103 | - | ||
104 | - // No objects found | ||
105 | - if ( ! $response->hasObject()) { | ||
106 | - return false; | ||
107 | - } | ||
108 | - | ||
109 | - $object = $response->getFirstObject(); | ||
110 | - | ||
111 | - // Check for expired object | ||
112 | - if ($this->isExpired($object)) { | ||
113 | - $this->bucket->delete($object); | ||
114 | - | ||
115 | - return false; | ||
116 | - } | ||
117 | - | ||
118 | - return true; | ||
119 | - } catch (Exception\RiakException $e) { | ||
120 | - // Do nothing | ||
121 | - } | ||
122 | - | ||
123 | - return false; | ||
124 | - } | ||
125 | - | ||
126 | - /** | ||
127 | - * {@inheritdoc} | ||
128 | - */ | ||
129 | - protected function doSave($id, $data, $lifeTime = 0) | ||
130 | - { | ||
131 | - try { | ||
132 | - $object = new Object($id); | ||
133 | - | ||
134 | - $object->setContent(serialize($data)); | ||
135 | - | ||
136 | - if ($lifeTime > 0) { | ||
137 | - $object->addMetadata(self::EXPIRES_HEADER, (string) (time() + $lifeTime)); | ||
138 | - } | ||
139 | - | ||
140 | - $this->bucket->put($object); | ||
141 | - | ||
142 | - return true; | ||
143 | - } catch (Exception\RiakException $e) { | ||
144 | - // Do nothing | ||
145 | - } | ||
146 | - | ||
147 | - return false; | ||
148 | - } | ||
149 | - | ||
150 | - /** | ||
151 | - * {@inheritdoc} | ||
152 | - */ | ||
153 | - protected function doDelete($id) | ||
154 | - { | ||
155 | - try { | ||
156 | - $this->bucket->delete($id); | ||
157 | - | ||
158 | - return true; | ||
159 | - } catch (Exception\BadArgumentsException $e) { | ||
160 | - // Key did not exist on cluster already | ||
161 | - } catch (Exception\RiakException $e) { | ||
162 | - // Covers: | ||
163 | - // - Riak\Exception\ConnectionException | ||
164 | - // - Riak\Exception\CommunicationException | ||
165 | - // - Riak\Exception\UnexpectedResponseException | ||
166 | - } | ||
167 | - | ||
168 | - return false; | ||
169 | - } | ||
170 | - | ||
171 | - /** | ||
172 | - * {@inheritdoc} | ||
173 | - */ | ||
174 | - protected function doFlush() | ||
175 | - { | ||
176 | - try { | ||
177 | - $keyList = $this->bucket->getKeyList(); | ||
178 | - | ||
179 | - foreach ($keyList as $key) { | ||
180 | - $this->bucket->delete($key); | ||
181 | - } | ||
182 | - | ||
183 | - return true; | ||
184 | - } catch (Exception\RiakException $e) { | ||
185 | - // Do nothing | ||
186 | - } | ||
187 | - | ||
188 | - return false; | ||
189 | - } | ||
190 | - | ||
191 | - /** | ||
192 | - * {@inheritdoc} | ||
193 | - */ | ||
194 | - protected function doGetStats() | ||
195 | - { | ||
196 | - // Only exposed through HTTP stats API, not Protocol Buffers API | ||
197 | - return null; | ||
198 | - } | ||
199 | - | ||
200 | - /** | ||
201 | - * Check if a given Riak Object have expired. | ||
202 | - * | ||
203 | - * @param \Riak\Object $object | ||
204 | - * | ||
205 | - * @return boolean | ||
206 | - */ | ||
207 | - private function isExpired(Object $object) | ||
208 | - { | ||
209 | - $metadataMap = $object->getMetadataMap(); | ||
210 | - | ||
211 | - return isset($metadataMap[self::EXPIRES_HEADER]) | ||
212 | - && $metadataMap[self::EXPIRES_HEADER] < time(); | ||
213 | - } | ||
214 | - | ||
215 | - /** | ||
216 | - * On-read conflict resolution. Applied approach here is last write wins. | ||
217 | - * Specific needs may override this method to apply alternate conflict resolutions. | ||
218 | - * | ||
219 | - * {@internal Riak does not attempt to resolve a write conflict, and store | ||
220 | - * it as sibling of conflicted one. By following this approach, it is up to | ||
221 | - * the next read to resolve the conflict. When this happens, your fetched | ||
222 | - * object will have a list of siblings (read as a list of objects). | ||
223 | - * In our specific case, we do not care about the intermediate ones since | ||
224 | - * they are all the same read from storage, and we do apply a last sibling | ||
225 | - * (last write) wins logic. | ||
226 | - * If by any means our resolution generates another conflict, it'll up to | ||
227 | - * next read to properly solve it.} | ||
228 | - * | ||
229 | - * @param string $id | ||
230 | - * @param string $vClock | ||
231 | - * @param array $objectList | ||
232 | - * | ||
233 | - * @return \Riak\Object | ||
234 | - */ | ||
235 | - protected function resolveConflict($id, $vClock, array $objectList) | ||
236 | - { | ||
237 | - // Our approach here is last-write wins | ||
238 | - $winner = $objectList[count($objectList)]; | ||
239 | - | ||
240 | - $putInput = new Input\PutInput(); | ||
241 | - $putInput->setVClock($vClock); | ||
242 | - | ||
243 | - $mergedObject = new Object($id); | ||
244 | - $mergedObject->setContent($winner->getContent()); | ||
245 | - | ||
246 | - $this->bucket->put($mergedObject, $putInput); | ||
247 | - | ||
248 | - return $mergedObject; | ||
249 | - } | ||
250 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -use SQLite3; | ||
23 | -use SQLite3Result; | ||
24 | - | ||
25 | -/** | ||
26 | - * SQLite3 cache provider. | ||
27 | - * | ||
28 | - * @since 1.4 | ||
29 | - * @author Jake Bell <jake@theunraveler.com> | ||
30 | - */ | ||
31 | -class SQLite3Cache extends CacheProvider | ||
32 | -{ | ||
33 | - /** | ||
34 | - * The ID field will store the cache key. | ||
35 | - */ | ||
36 | - const ID_FIELD = 'k'; | ||
37 | - | ||
38 | - /** | ||
39 | - * The data field will store the serialized PHP value. | ||
40 | - */ | ||
41 | - const DATA_FIELD = 'd'; | ||
42 | - | ||
43 | - /** | ||
44 | - * The expiration field will store a date value indicating when the | ||
45 | - * cache entry should expire. | ||
46 | - */ | ||
47 | - const EXPIRATION_FIELD = 'e'; | ||
48 | - | ||
49 | - /** | ||
50 | - * @var SQLite3 | ||
51 | - */ | ||
52 | - private $sqlite; | ||
53 | - | ||
54 | - /** | ||
55 | - * @var string | ||
56 | - */ | ||
57 | - private $table; | ||
58 | - | ||
59 | - /** | ||
60 | - * Constructor. | ||
61 | - * | ||
62 | - * Calling the constructor will ensure that the database file and table | ||
63 | - * exist and will create both if they don't. | ||
64 | - * | ||
65 | - * @param SQLite3 $sqlite | ||
66 | - * @param string $table | ||
67 | - */ | ||
68 | - public function __construct(SQLite3 $sqlite, $table) | ||
69 | - { | ||
70 | - $this->sqlite = $sqlite; | ||
71 | - $this->table = (string) $table; | ||
72 | - | ||
73 | - list($id, $data, $exp) = $this->getFields(); | ||
74 | - | ||
75 | - return $this->sqlite->exec(sprintf( | ||
76 | - 'CREATE TABLE IF NOT EXISTS %s(%s TEXT PRIMARY KEY NOT NULL, %s BLOB, %s INTEGER)', | ||
77 | - $table, | ||
78 | - $id, | ||
79 | - $data, | ||
80 | - $exp | ||
81 | - )); | ||
82 | - } | ||
83 | - | ||
84 | - /** | ||
85 | - * {@inheritdoc} | ||
86 | - */ | ||
87 | - protected function doFetch($id) | ||
88 | - { | ||
89 | - if ($item = $this->findById($id)) { | ||
90 | - return unserialize($item[self::DATA_FIELD]); | ||
91 | - } | ||
92 | - | ||
93 | - return false; | ||
94 | - } | ||
95 | - | ||
96 | - /** | ||
97 | - * {@inheritdoc} | ||
98 | - */ | ||
99 | - protected function doContains($id) | ||
100 | - { | ||
101 | - return (boolean) $this->findById($id, false); | ||
102 | - } | ||
103 | - | ||
104 | - /** | ||
105 | - * {@inheritdoc} | ||
106 | - */ | ||
107 | - protected function doSave($id, $data, $lifeTime = 0) | ||
108 | - { | ||
109 | - $statement = $this->sqlite->prepare(sprintf( | ||
110 | - 'INSERT OR REPLACE INTO %s (%s) VALUES (:id, :data, :expire)', | ||
111 | - $this->table, | ||
112 | - implode(',', $this->getFields()) | ||
113 | - )); | ||
114 | - | ||
115 | - $statement->bindValue(':id', $id); | ||
116 | - $statement->bindValue(':data', serialize($data), SQLITE3_BLOB); | ||
117 | - $statement->bindValue(':expire', $lifeTime > 0 ? time() + $lifeTime : null); | ||
118 | - | ||
119 | - return $statement->execute() instanceof SQLite3Result; | ||
120 | - } | ||
121 | - | ||
122 | - /** | ||
123 | - * {@inheritdoc} | ||
124 | - */ | ||
125 | - protected function doDelete($id) | ||
126 | - { | ||
127 | - list($idField) = $this->getFields(); | ||
128 | - | ||
129 | - $statement = $this->sqlite->prepare(sprintf( | ||
130 | - 'DELETE FROM %s WHERE %s = :id', | ||
131 | - $this->table, | ||
132 | - $idField | ||
133 | - )); | ||
134 | - | ||
135 | - $statement->bindValue(':id', $id); | ||
136 | - | ||
137 | - return $statement->execute() instanceof SQLite3Result; | ||
138 | - } | ||
139 | - | ||
140 | - /** | ||
141 | - * {@inheritdoc} | ||
142 | - */ | ||
143 | - protected function doFlush() | ||
144 | - { | ||
145 | - return $this->sqlite->exec(sprintf('DELETE FROM %s', $this->table)); | ||
146 | - } | ||
147 | - | ||
148 | - /** | ||
149 | - * {@inheritdoc} | ||
150 | - */ | ||
151 | - protected function doGetStats() | ||
152 | - { | ||
153 | - // no-op. | ||
154 | - } | ||
155 | - | ||
156 | - /** | ||
157 | - * Find a single row by ID. | ||
158 | - * | ||
159 | - * @param mixed $id | ||
160 | - * @param boolean $includeData | ||
161 | - * | ||
162 | - * @return array|null | ||
163 | - */ | ||
164 | - private function findById($id, $includeData = true) | ||
165 | - { | ||
166 | - list($idField) = $fields = $this->getFields(); | ||
167 | - | ||
168 | - if (!$includeData) { | ||
169 | - $key = array_search(static::DATA_FIELD, $fields); | ||
170 | - unset($fields[$key]); | ||
171 | - } | ||
172 | - | ||
173 | - $statement = $this->sqlite->prepare(sprintf( | ||
174 | - 'SELECT %s FROM %s WHERE %s = :id LIMIT 1', | ||
175 | - implode(',', $fields), | ||
176 | - $this->table, | ||
177 | - $idField | ||
178 | - )); | ||
179 | - | ||
180 | - $statement->bindValue(':id', $id, SQLITE3_TEXT); | ||
181 | - | ||
182 | - $item = $statement->execute()->fetchArray(SQLITE3_ASSOC); | ||
183 | - | ||
184 | - if ($item === false) { | ||
185 | - return null; | ||
186 | - } | ||
187 | - | ||
188 | - if ($this->isExpired($item)) { | ||
189 | - $this->doDelete($id); | ||
190 | - | ||
191 | - return null; | ||
192 | - } | ||
193 | - | ||
194 | - return $item; | ||
195 | - } | ||
196 | - | ||
197 | - /** | ||
198 | - * Gets an array of the fields in our table. | ||
199 | - * | ||
200 | - * @return array | ||
201 | - */ | ||
202 | - private function getFields() | ||
203 | - { | ||
204 | - return array(static::ID_FIELD, static::DATA_FIELD, static::EXPIRATION_FIELD); | ||
205 | - } | ||
206 | - | ||
207 | - /** | ||
208 | - * Check if the item is expired. | ||
209 | - * | ||
210 | - * @param array $item | ||
211 | - * @return boolean | ||
212 | - */ | ||
213 | - private function isExpired(array $item) | ||
214 | - { | ||
215 | - return isset($item[static::EXPIRATION_FIELD]) && | ||
216 | - $item[self::EXPIRATION_FIELD] !== null && | ||
217 | - $item[self::EXPIRATION_FIELD] < time(); | ||
218 | - } | ||
219 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -class Version | ||
23 | -{ | ||
24 | - const VERSION = '1.4.4'; | ||
25 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Void cache driver. The cache could be of use in tests where you don`t need to cache anything. | ||
24 | - * | ||
25 | - * @link www.doctrine-project.org | ||
26 | - * @since 1.5 | ||
27 | - * @author Kotlyar Maksim <kotlyar.maksim@gmail.com> | ||
28 | - */ | ||
29 | -class VoidCache extends CacheProvider | ||
30 | -{ | ||
31 | - /** | ||
32 | - * {@inheritDoc} | ||
33 | - */ | ||
34 | - protected function doFetch($id) | ||
35 | - { | ||
36 | - return false; | ||
37 | - } | ||
38 | - | ||
39 | - /** | ||
40 | - * {@inheritDoc} | ||
41 | - */ | ||
42 | - protected function doContains($id) | ||
43 | - { | ||
44 | - return false; | ||
45 | - } | ||
46 | - | ||
47 | - /** | ||
48 | - * {@inheritDoc} | ||
49 | - */ | ||
50 | - protected function doSave($id, $data, $lifeTime = 0) | ||
51 | - { | ||
52 | - return true; | ||
53 | - } | ||
54 | - | ||
55 | - /** | ||
56 | - * {@inheritDoc} | ||
57 | - */ | ||
58 | - protected function doDelete($id) | ||
59 | - { | ||
60 | - return true; | ||
61 | - } | ||
62 | - | ||
63 | - /** | ||
64 | - * {@inheritDoc} | ||
65 | - */ | ||
66 | - protected function doFlush() | ||
67 | - { | ||
68 | - return true; | ||
69 | - } | ||
70 | - | ||
71 | - /** | ||
72 | - * {@inheritDoc} | ||
73 | - */ | ||
74 | - protected function doGetStats() | ||
75 | - { | ||
76 | - return; | ||
77 | - } | ||
78 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * WinCache cache provider. | ||
24 | - * | ||
25 | - * @link www.doctrine-project.org | ||
26 | - * @since 2.2 | ||
27 | - * @author Benjamin Eberlei <kontakt@beberlei.de> | ||
28 | - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
29 | - * @author Jonathan Wage <jonwage@gmail.com> | ||
30 | - * @author Roman Borschel <roman@code-factory.org> | ||
31 | - * @author David Abdemoulaie <dave@hobodave.com> | ||
32 | - */ | ||
33 | -class WinCacheCache extends CacheProvider | ||
34 | -{ | ||
35 | - /** | ||
36 | - * {@inheritdoc} | ||
37 | - */ | ||
38 | - protected function doFetch($id) | ||
39 | - { | ||
40 | - return wincache_ucache_get($id); | ||
41 | - } | ||
42 | - | ||
43 | - /** | ||
44 | - * {@inheritdoc} | ||
45 | - */ | ||
46 | - protected function doContains($id) | ||
47 | - { | ||
48 | - return wincache_ucache_exists($id); | ||
49 | - } | ||
50 | - | ||
51 | - /** | ||
52 | - * {@inheritdoc} | ||
53 | - */ | ||
54 | - protected function doSave($id, $data, $lifeTime = 0) | ||
55 | - { | ||
56 | - return (bool) wincache_ucache_set($id, $data, (int) $lifeTime); | ||
57 | - } | ||
58 | - | ||
59 | - /** | ||
60 | - * {@inheritdoc} | ||
61 | - */ | ||
62 | - protected function doDelete($id) | ||
63 | - { | ||
64 | - return wincache_ucache_delete($id); | ||
65 | - } | ||
66 | - | ||
67 | - /** | ||
68 | - * {@inheritdoc} | ||
69 | - */ | ||
70 | - protected function doFlush() | ||
71 | - { | ||
72 | - return wincache_ucache_clear(); | ||
73 | - } | ||
74 | - | ||
75 | - /** | ||
76 | - * {@inheritdoc} | ||
77 | - */ | ||
78 | - protected function doGetStats() | ||
79 | - { | ||
80 | - $info = wincache_ucache_info(); | ||
81 | - $meminfo = wincache_ucache_meminfo(); | ||
82 | - | ||
83 | - return array( | ||
84 | - Cache::STATS_HITS => $info['total_hit_count'], | ||
85 | - Cache::STATS_MISSES => $info['total_miss_count'], | ||
86 | - Cache::STATS_UPTIME => $info['total_cache_uptime'], | ||
87 | - Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'], | ||
88 | - Cache::STATS_MEMORY_AVAILABLE => $meminfo['memory_free'], | ||
89 | - ); | ||
90 | - } | ||
91 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Xcache cache driver. | ||
24 | - * | ||
25 | - * @link www.doctrine-project.org | ||
26 | - * @since 2.0 | ||
27 | - * @author Benjamin Eberlei <kontakt@beberlei.de> | ||
28 | - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
29 | - * @author Jonathan Wage <jonwage@gmail.com> | ||
30 | - * @author Roman Borschel <roman@code-factory.org> | ||
31 | - * @author David Abdemoulaie <dave@hobodave.com> | ||
32 | - */ | ||
33 | -class XcacheCache extends CacheProvider | ||
34 | -{ | ||
35 | - /** | ||
36 | - * {@inheritdoc} | ||
37 | - */ | ||
38 | - protected function doFetch($id) | ||
39 | - { | ||
40 | - return $this->doContains($id) ? unserialize(xcache_get($id)) : false; | ||
41 | - } | ||
42 | - | ||
43 | - /** | ||
44 | - * {@inheritdoc} | ||
45 | - */ | ||
46 | - protected function doContains($id) | ||
47 | - { | ||
48 | - return xcache_isset($id); | ||
49 | - } | ||
50 | - | ||
51 | - /** | ||
52 | - * {@inheritdoc} | ||
53 | - */ | ||
54 | - protected function doSave($id, $data, $lifeTime = 0) | ||
55 | - { | ||
56 | - return xcache_set($id, serialize($data), (int) $lifeTime); | ||
57 | - } | ||
58 | - | ||
59 | - /** | ||
60 | - * {@inheritdoc} | ||
61 | - */ | ||
62 | - protected function doDelete($id) | ||
63 | - { | ||
64 | - return xcache_unset($id); | ||
65 | - } | ||
66 | - | ||
67 | - /** | ||
68 | - * {@inheritdoc} | ||
69 | - */ | ||
70 | - protected function doFlush() | ||
71 | - { | ||
72 | - $this->checkAuthorization(); | ||
73 | - | ||
74 | - xcache_clear_cache(XC_TYPE_VAR); | ||
75 | - | ||
76 | - return true; | ||
77 | - } | ||
78 | - | ||
79 | - /** | ||
80 | - * Checks that xcache.admin.enable_auth is Off. | ||
81 | - * | ||
82 | - * @return void | ||
83 | - * | ||
84 | - * @throws \BadMethodCallException When xcache.admin.enable_auth is On. | ||
85 | - */ | ||
86 | - protected function checkAuthorization() | ||
87 | - { | ||
88 | - if (ini_get('xcache.admin.enable_auth')) { | ||
89 | - throw new \BadMethodCallException( | ||
90 | - 'To use all features of \Doctrine\Common\Cache\XcacheCache, ' | ||
91 | - . 'you must set "xcache.admin.enable_auth" to "Off" in your php.ini.' | ||
92 | - ); | ||
93 | - } | ||
94 | - } | ||
95 | - | ||
96 | - /** | ||
97 | - * {@inheritdoc} | ||
98 | - */ | ||
99 | - protected function doGetStats() | ||
100 | - { | ||
101 | - $this->checkAuthorization(); | ||
102 | - | ||
103 | - $info = xcache_info(XC_TYPE_VAR, 0); | ||
104 | - return array( | ||
105 | - Cache::STATS_HITS => $info['hits'], | ||
106 | - Cache::STATS_MISSES => $info['misses'], | ||
107 | - Cache::STATS_UPTIME => null, | ||
108 | - Cache::STATS_MEMORY_USAGE => $info['size'], | ||
109 | - Cache::STATS_MEMORY_AVAILABLE => $info['avail'], | ||
110 | - ); | ||
111 | - } | ||
112 | -} |
1 | -<?php | ||
2 | -/* | ||
3 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
4 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
5 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
6 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
7 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
8 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
9 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
10 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
11 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
12 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
13 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
14 | - * | ||
15 | - * This software consists of voluntary contributions made by many individuals | ||
16 | - * and is licensed under the MIT license. For more information, see | ||
17 | - * <http://www.doctrine-project.org>. | ||
18 | - */ | ||
19 | - | ||
20 | -namespace Doctrine\Common\Cache; | ||
21 | - | ||
22 | -/** | ||
23 | - * Zend Data Cache cache driver. | ||
24 | - * | ||
25 | - * @link www.doctrine-project.org | ||
26 | - * @since 2.0 | ||
27 | - * @author Ralph Schindler <ralph.schindler@zend.com> | ||
28 | - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
29 | - */ | ||
30 | -class ZendDataCache extends CacheProvider | ||
31 | -{ | ||
32 | - /** | ||
33 | - * {@inheritdoc} | ||
34 | - */ | ||
35 | - protected function doFetch($id) | ||
36 | - { | ||
37 | - return zend_shm_cache_fetch($id); | ||
38 | - } | ||
39 | - | ||
40 | - /** | ||
41 | - * {@inheritdoc} | ||
42 | - */ | ||
43 | - protected function doContains($id) | ||
44 | - { | ||
45 | - return (false !== zend_shm_cache_fetch($id)); | ||
46 | - } | ||
47 | - | ||
48 | - /** | ||
49 | - * {@inheritdoc} | ||
50 | - */ | ||
51 | - protected function doSave($id, $data, $lifeTime = 0) | ||
52 | - { | ||
53 | - return zend_shm_cache_store($id, $data, $lifeTime); | ||
54 | - } | ||
55 | - | ||
56 | - /** | ||
57 | - * {@inheritdoc} | ||
58 | - */ | ||
59 | - protected function doDelete($id) | ||
60 | - { | ||
61 | - return zend_shm_cache_delete($id); | ||
62 | - } | ||
63 | - | ||
64 | - /** | ||
65 | - * {@inheritdoc} | ||
66 | - */ | ||
67 | - protected function doFlush() | ||
68 | - { | ||
69 | - $namespace = $this->getNamespace(); | ||
70 | - if (empty($namespace)) { | ||
71 | - return zend_shm_cache_clear(); | ||
72 | - } | ||
73 | - return zend_shm_cache_clear($namespace); | ||
74 | - } | ||
75 | - | ||
76 | - /** | ||
77 | - * {@inheritdoc} | ||
78 | - */ | ||
79 | - protected function doGetStats() | ||
80 | - { | ||
81 | - return null; | ||
82 | - } | ||
83 | -} |
vendor/doctrine/cache/phpunit.xml.dist
已删除
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | - | ||
3 | -<phpunit backupGlobals="false" | ||
4 | - backupStaticAttributes="false" | ||
5 | - colors="true" | ||
6 | - convertErrorsToExceptions="true" | ||
7 | - convertNoticesToExceptions="true" | ||
8 | - convertWarningsToExceptions="true" | ||
9 | - processIsolation="false" | ||
10 | - stopOnFailure="false" | ||
11 | - syntaxCheck="false" | ||
12 | - bootstrap="./tests/Doctrine/Tests/TestInit.php" | ||
13 | -> | ||
14 | - <testsuites> | ||
15 | - <testsuite name="Doctrine Cache Test Suite"> | ||
16 | - <directory>./tests/Doctrine/</directory> | ||
17 | - </testsuite> | ||
18 | - </testsuites> | ||
19 | - | ||
20 | - <filter> | ||
21 | - <whitelist> | ||
22 | - <directory>./lib/Doctrine/</directory> | ||
23 | - </whitelist> | ||
24 | - </filter> | ||
25 | -</phpunit> |
1 | -<?php | ||
2 | - | ||
3 | -namespace Doctrine\Tests\Common\Cache; | ||
4 | - | ||
5 | -use Doctrine\Common\Cache\ApcCache; | ||
6 | - | ||
7 | -class ApcCacheTest extends CacheTest | ||
8 | -{ | ||
9 | - public function setUp() | ||
10 | - { | ||
11 | - if ( ! extension_loaded('apc') || false === @apc_cache_info()) { | ||
12 | - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of APC'); | ||
13 | - } | ||
14 | - } | ||
15 | - | ||
16 | - protected function _getCacheDriver() | ||
17 | - { | ||
18 | - return new ApcCache(); | ||
19 | - } | ||
20 | -} |
1 | -<?php | ||
2 | - | ||
3 | -namespace Doctrine\Tests\Common\Cache; | ||
4 | - | ||
5 | -use Doctrine\Common\Cache\ArrayCache; | ||
6 | - | ||
7 | -class ArrayCacheTest extends CacheTest | ||
8 | -{ | ||
9 | - protected function _getCacheDriver() | ||
10 | - { | ||
11 | - return new ArrayCache(); | ||
12 | - } | ||
13 | - | ||
14 | - public function testGetStats() | ||
15 | - { | ||
16 | - $cache = $this->_getCacheDriver(); | ||
17 | - $stats = $cache->getStats(); | ||
18 | - | ||
19 | - $this->assertNull($stats); | ||
20 | - } | ||
21 | - | ||
22 | - protected function isSharedStorage() | ||
23 | - { | ||
24 | - return false; | ||
25 | - } | ||
26 | -} |
1 | -<?php | ||
2 | - | ||
3 | -namespace Doctrine\Tests\Common\Cache; | ||
4 | - | ||
5 | -use RecursiveDirectoryIterator; | ||
6 | -use RecursiveIteratorIterator; | ||
7 | - | ||
8 | -abstract class BaseFileCacheTest extends CacheTest | ||
9 | -{ | ||
10 | - protected $directory; | ||
11 | - | ||
12 | - public function testFlushAllRemovesBalancingDirectories() | ||
13 | - { | ||
14 | - $cache = $this->_getCacheDriver(); | ||
15 | - | ||
16 | - $this->assertTrue($cache->save('key1', 1)); | ||
17 | - $this->assertTrue($cache->save('key2', 2)); | ||
18 | - $this->assertTrue($cache->flushAll()); | ||
19 | - | ||
20 | - $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST); | ||
21 | - | ||
22 | - $this->assertCount(0, $iterator); | ||
23 | - } | ||
24 | - | ||
25 | - protected function setUp() | ||
26 | - { | ||
27 | - do { | ||
28 | - $this->directory = sys_get_temp_dir() . '/doctrine_cache_'. uniqid(); | ||
29 | - } while (file_exists($this->directory)); | ||
30 | - } | ||
31 | - | ||
32 | - protected function tearDown() | ||
33 | - { | ||
34 | - if ( ! is_dir($this->directory)) { | ||
35 | - return; | ||
36 | - } | ||
37 | - | ||
38 | - $iterator = new RecursiveDirectoryIterator($this->directory); | ||
39 | - | ||
40 | - foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) { | ||
41 | - if ($file->isFile()) { | ||
42 | - @unlink($file->getRealPath()); | ||
43 | - } elseif ($file->isDir()) { | ||
44 | - @rmdir($file->getRealPath()); | ||
45 | - } | ||
46 | - } | ||
47 | - | ||
48 | - @rmdir($this->directory); | ||
49 | - } | ||
50 | - | ||
51 | - protected function isSharedStorage() | ||
52 | - { | ||
53 | - return false; | ||
54 | - } | ||
55 | -} |
1 | -<?php | ||
2 | - | ||
3 | -namespace Doctrine\Tests\Common\Cache; | ||
4 | - | ||
5 | -class CacheProviderTest extends \Doctrine\Tests\DoctrineTestCase | ||
6 | -{ | ||
7 | - public function testFetchMultiWillFilterNonRequestedKeys() | ||
8 | - { | ||
9 | - /* @var $cache \Doctrine\Common\Cache\CacheProvider|\PHPUnit_Framework_MockObject_MockObject */ | ||
10 | - $cache = $this->getMockForAbstractClass( | ||
11 | - 'Doctrine\Common\Cache\CacheProvider', | ||
12 | - array(), | ||
13 | - '', | ||
14 | - true, | ||
15 | - true, | ||
16 | - true, | ||
17 | - array('doFetchMultiple') | ||
18 | - ); | ||
19 | - | ||
20 | - $cache | ||
21 | - ->expects($this->once()) | ||
22 | - ->method('doFetchMultiple') | ||
23 | - ->will($this->returnValue(array( | ||
24 | - '[foo][1]' => 'bar', | ||
25 | - '[bar][1]' => 'baz', | ||
26 | - '[baz][1]' => 'tab', | ||
27 | - ))); | ||
28 | - | ||
29 | - $this->assertEquals( | ||
30 | - array('foo' => 'bar', 'bar' => 'baz'), | ||
31 | - $cache->fetchMultiple(array('foo', 'bar')) | ||
32 | - ); | ||
33 | - } | ||
34 | - | ||
35 | - public function testFailedDeleteAllDoesNotChangeNamespaceVersion() | ||
36 | - { | ||
37 | - /* @var $cache \Doctrine\Common\Cache\CacheProvider|\PHPUnit_Framework_MockObject_MockObject */ | ||
38 | - $cache = $this->getMockForAbstractClass( | ||
39 | - 'Doctrine\Common\Cache\CacheProvider', | ||
40 | - array(), | ||
41 | - '', | ||
42 | - true, | ||
43 | - true, | ||
44 | - true, | ||
45 | - array('doFetch', 'doSave', 'doContains') | ||
46 | - ); | ||
47 | - | ||
48 | - $cache | ||
49 | - ->expects($this->once()) | ||
50 | - ->method('doFetch') | ||
51 | - ->with('DoctrineNamespaceCacheKey[]') | ||
52 | - ->will($this->returnValue(false)); | ||
53 | - | ||
54 | - // doSave is only called once from deleteAll as we do not need to persist the default version in getNamespaceVersion() | ||
55 | - $cache | ||
56 | - ->expects($this->once()) | ||
57 | - ->method('doSave') | ||
58 | - ->with('DoctrineNamespaceCacheKey[]') | ||
59 | - ->will($this->returnValue(false)); | ||
60 | - | ||
61 | - // After a failed deleteAll() the local namespace version is not increased (still 1). Otherwise all data written afterwards | ||
62 | - // would be lost outside the current instance. | ||
63 | - $cache | ||
64 | - ->expects($this->once()) | ||
65 | - ->method('doContains') | ||
66 | - ->with('[key][1]') | ||
67 | - ->will($this->returnValue(true)); | ||
68 | - | ||
69 | - $this->assertFalse($cache->deleteAll(), 'deleteAll() returns false when saving the namespace version fails'); | ||
70 | - $cache->contains('key'); | ||
71 | - } | ||
72 | -} |
1 | -<?php | ||
2 | - | ||
3 | -namespace Doctrine\Tests\Common\Cache; | ||
4 | - | ||
5 | -use Doctrine\Common\Cache\Cache; | ||
6 | -use ArrayObject; | ||
7 | - | ||
8 | -abstract class CacheTest extends \Doctrine\Tests\DoctrineTestCase | ||
9 | -{ | ||
10 | - /** | ||
11 | - * @dataProvider provideDataToCache | ||
12 | - */ | ||
13 | - public function testSetContainsFetchDelete($value) | ||
14 | - { | ||
15 | - $cache = $this->_getCacheDriver(); | ||
16 | - | ||
17 | - // Test saving a value, checking if it exists, and fetching it back | ||
18 | - $this->assertTrue($cache->save('key', $value)); | ||
19 | - $this->assertTrue($cache->contains('key')); | ||
20 | - if (is_object($value)) { | ||
21 | - $this->assertEquals($value, $cache->fetch('key'), 'Objects retrieved from the cache must be equal but not necessarily the same reference'); | ||
22 | - } else { | ||
23 | - $this->assertSame($value, $cache->fetch('key'), 'Scalar and array data retrieved from the cache must be the same as the original, e.g. same type'); | ||
24 | - } | ||
25 | - | ||
26 | - // Test deleting a value | ||
27 | - $this->assertTrue($cache->delete('key')); | ||
28 | - $this->assertFalse($cache->contains('key')); | ||
29 | - $this->assertFalse($cache->fetch('key')); | ||
30 | - } | ||
31 | - | ||
32 | - /** | ||
33 | - * @dataProvider provideDataToCache | ||
34 | - */ | ||
35 | - public function testUpdateExistingEntry($value) | ||
36 | - { | ||
37 | - $cache = $this->_getCacheDriver(); | ||
38 | - | ||
39 | - $this->assertTrue($cache->save('key', 'old-value')); | ||
40 | - $this->assertTrue($cache->contains('key')); | ||
41 | - | ||
42 | - $this->assertTrue($cache->save('key', $value)); | ||
43 | - $this->assertTrue($cache->contains('key')); | ||
44 | - if (is_object($value)) { | ||
45 | - $this->assertEquals($value, $cache->fetch('key'), 'Objects retrieved from the cache must be equal but not necessarily the same reference'); | ||
46 | - } else { | ||
47 | - $this->assertSame($value, $cache->fetch('key'), 'Scalar and array data retrieved from the cache must be the same as the original, e.g. same type'); | ||
48 | - } | ||
49 | - } | ||
50 | - | ||
51 | - public function testFetchMulti() | ||
52 | - { | ||
53 | - $cache = $this->_getCacheDriver(); | ||
54 | - | ||
55 | - $cache->deleteAll(); | ||
56 | - | ||
57 | - // Test saving some values, checking if it exists, and fetching it back with multiGet | ||
58 | - $this->assertTrue($cache->save('key1', 'value1')); | ||
59 | - $this->assertTrue($cache->save('key2', 'value2')); | ||
60 | - | ||
61 | - $this->assertEquals( | ||
62 | - array('key1' => 'value1', 'key2' => 'value2'), | ||
63 | - $cache->fetchMultiple(array('key1', 'key2')) | ||
64 | - ); | ||
65 | - $this->assertEquals( | ||
66 | - array('key1' => 'value1', 'key2' => 'value2'), | ||
67 | - $cache->fetchMultiple(array('key1', 'key3', 'key2')) | ||
68 | - ); | ||
69 | - $this->assertEquals( | ||
70 | - array('key1' => 'value1', 'key2' => 'value2'), | ||
71 | - $cache->fetchMultiple(array('key1', 'key2', 'key3')) | ||
72 | - ); | ||
73 | - } | ||
74 | - | ||
75 | - public function testFetchMultiWithEmptyKeysArray() | ||
76 | - { | ||
77 | - $cache = $this->_getCacheDriver(); | ||
78 | - | ||
79 | - $this->assertEmpty( | ||
80 | - $cache->fetchMultiple(array()) | ||
81 | - ); | ||
82 | - } | ||
83 | - | ||
84 | - public function testFetchMultiWithFalsey() | ||
85 | - { | ||
86 | - $cache = $this->_getCacheDriver(); | ||
87 | - | ||
88 | - $cache->deleteAll(); | ||
89 | - | ||
90 | - $values = array( | ||
91 | - 'string' => 'str', | ||
92 | - 'integer' => 1, | ||
93 | - 'boolean' => true, | ||
94 | - 'null' => null, | ||
95 | - 'array_empty' => array(), | ||
96 | - 'integer_zero' => 0, | ||
97 | - 'string_empty' => '' | ||
98 | - ); | ||
99 | - foreach ($values AS $key => $value) { | ||
100 | - $cache->save($key, $value); | ||
101 | - } | ||
102 | - | ||
103 | - $this->assertEquals( | ||
104 | - $values, | ||
105 | - $cache->fetchMultiple(array_keys($values)) | ||
106 | - ); | ||
107 | - } | ||
108 | - | ||
109 | - public function provideDataToCache() | ||
110 | - { | ||
111 | - return array( | ||
112 | - 'array' => array(array('one', 2, 3.01)), | ||
113 | - 'string' => array('value'), | ||
114 | - 'integer' => array(1), | ||
115 | - 'float' => array(1.5), | ||
116 | - 'object' => array(new ArrayObject()), | ||
117 | - 'true' => array(true), | ||
118 | - // the following are considered FALSE in boolean context, but caches should still recognize their existence | ||
119 | - 'null' => array(null), | ||
120 | - 'false' => array(false), | ||
121 | - 'array_empty' => array(array()), | ||
122 | - 'string_zero' => array('0'), | ||
123 | - 'integer_zero' => array(0), | ||
124 | - 'float_zero' => array(0.0), | ||
125 | - 'string_empty' => array('') | ||
126 | - ); | ||
127 | - } | ||
128 | - | ||
129 | - public function testDeleteIsSuccessfulWhenKeyDoesNotExist() | ||
130 | - { | ||
131 | - $cache = $this->_getCacheDriver(); | ||
132 | - | ||
133 | - $this->assertFalse($cache->contains('key')); | ||
134 | - $this->assertTrue($cache->delete('key')); | ||
135 | - } | ||
136 | - | ||
137 | - public function testDeleteAll() | ||
138 | - { | ||
139 | - $cache = $this->_getCacheDriver(); | ||
140 | - | ||
141 | - $this->assertTrue($cache->save('key1', 1)); | ||
142 | - $this->assertTrue($cache->save('key2', 2)); | ||
143 | - $this->assertTrue($cache->deleteAll()); | ||
144 | - $this->assertFalse($cache->contains('key1')); | ||
145 | - $this->assertFalse($cache->contains('key2')); | ||
146 | - } | ||
147 | - | ||
148 | - public function testDeleteAllAndNamespaceVersioningBetweenCaches() | ||
149 | - { | ||
150 | - if ( ! $this->isSharedStorage()) { | ||
151 | - $this->markTestSkipped('The ' . __CLASS__ .' does not use shared storage'); | ||
152 | - } | ||
153 | - | ||
154 | - $cache1 = $this->_getCacheDriver(); | ||
155 | - $cache2 = $this->_getCacheDriver(); | ||
156 | - | ||
157 | - $this->assertTrue($cache1->save('key1', 1)); | ||
158 | - $this->assertTrue($cache2->save('key2', 2)); | ||
159 | - | ||
160 | - /* Both providers are initialized with the same namespace version, so | ||
161 | - * they can see entries set by each other. | ||
162 | - */ | ||
163 | - $this->assertTrue($cache1->contains('key1')); | ||
164 | - $this->assertTrue($cache1->contains('key2')); | ||
165 | - $this->assertTrue($cache2->contains('key1')); | ||
166 | - $this->assertTrue($cache2->contains('key2')); | ||
167 | - | ||
168 | - /* Deleting all entries through one provider will only increment the | ||
169 | - * namespace version on that object (and in the cache itself, which new | ||
170 | - * instances will use to initialize). The second provider will retain | ||
171 | - * its original version and still see stale data. | ||
172 | - */ | ||
173 | - $this->assertTrue($cache1->deleteAll()); | ||
174 | - $this->assertFalse($cache1->contains('key1')); | ||
175 | - $this->assertFalse($cache1->contains('key2')); | ||
176 | - $this->assertTrue($cache2->contains('key1')); | ||
177 | - $this->assertTrue($cache2->contains('key2')); | ||
178 | - | ||
179 | - /* A new cache provider should not see the deleted entries, since its | ||
180 | - * namespace version will be initialized. | ||
181 | - */ | ||
182 | - $cache3 = $this->_getCacheDriver(); | ||
183 | - $this->assertFalse($cache3->contains('key1')); | ||
184 | - $this->assertFalse($cache3->contains('key2')); | ||
185 | - } | ||
186 | - | ||
187 | - public function testFlushAll() | ||
188 | - { | ||
189 | - $cache = $this->_getCacheDriver(); | ||
190 | - | ||
191 | - $this->assertTrue($cache->save('key1', 1)); | ||
192 | - $this->assertTrue($cache->save('key2', 2)); | ||
193 | - $this->assertTrue($cache->flushAll()); | ||
194 | - $this->assertFalse($cache->contains('key1')); | ||
195 | - $this->assertFalse($cache->contains('key2')); | ||
196 | - } | ||
197 | - | ||
198 | - public function testFlushAllAndNamespaceVersioningBetweenCaches() | ||
199 | - { | ||
200 | - if ( ! $this->isSharedStorage()) { | ||
201 | - $this->markTestSkipped('The ' . __CLASS__ .' does not use shared storage'); | ||
202 | - } | ||
203 | - | ||
204 | - $cache1 = $this->_getCacheDriver(); | ||
205 | - $cache2 = $this->_getCacheDriver(); | ||
206 | - | ||
207 | - /* Deleting all elements from the first provider should increment its | ||
208 | - * namespace version before saving the first entry. | ||
209 | - */ | ||
210 | - $cache1->deleteAll(); | ||
211 | - $this->assertTrue($cache1->save('key1', 1)); | ||
212 | - | ||
213 | - /* The second provider will be initialized with the same namespace | ||
214 | - * version upon its first save operation. | ||
215 | - */ | ||
216 | - $this->assertTrue($cache2->save('key2', 2)); | ||
217 | - | ||
218 | - /* Both providers have the same namespace version and can see entries | ||
219 | - * set by each other. | ||
220 | - */ | ||
221 | - $this->assertTrue($cache1->contains('key1')); | ||
222 | - $this->assertTrue($cache1->contains('key2')); | ||
223 | - $this->assertTrue($cache2->contains('key1')); | ||
224 | - $this->assertTrue($cache2->contains('key2')); | ||
225 | - | ||
226 | - /* Flushing all entries through one cache will remove all entries from | ||
227 | - * the cache but leave their namespace version as-is. | ||
228 | - */ | ||
229 | - $this->assertTrue($cache1->flushAll()); | ||
230 | - $this->assertFalse($cache1->contains('key1')); | ||
231 | - $this->assertFalse($cache1->contains('key2')); | ||
232 | - $this->assertFalse($cache2->contains('key1')); | ||
233 | - $this->assertFalse($cache2->contains('key2')); | ||
234 | - | ||
235 | - /* Inserting a new entry will use the same, incremented namespace | ||
236 | - * version, and it will be visible to both providers. | ||
237 | - */ | ||
238 | - $this->assertTrue($cache1->save('key1', 1)); | ||
239 | - $this->assertTrue($cache1->contains('key1')); | ||
240 | - $this->assertTrue($cache2->contains('key1')); | ||
241 | - | ||
242 | - /* A new cache provider will be initialized with the original namespace | ||
243 | - * version and not share any visibility with the first two providers. | ||
244 | - */ | ||
245 | - $cache3 = $this->_getCacheDriver(); | ||
246 | - $this->assertFalse($cache3->contains('key1')); | ||
247 | - $this->assertFalse($cache3->contains('key2')); | ||
248 | - $this->assertTrue($cache3->save('key3', 3)); | ||
249 | - $this->assertTrue($cache3->contains('key3')); | ||
250 | - } | ||
251 | - | ||
252 | - public function testNamespace() | ||
253 | - { | ||
254 | - $cache = $this->_getCacheDriver(); | ||
255 | - | ||
256 | - $cache->setNamespace('ns1_'); | ||
257 | - | ||
258 | - $this->assertTrue($cache->save('key1', 1)); | ||
259 | - $this->assertTrue($cache->contains('key1')); | ||
260 | - | ||
261 | - $cache->setNamespace('ns2_'); | ||
262 | - | ||
263 | - $this->assertFalse($cache->contains('key1')); | ||
264 | - } | ||
265 | - | ||
266 | - public function testDeleteAllNamespace() | ||
267 | - { | ||
268 | - $cache = $this->_getCacheDriver(); | ||
269 | - | ||
270 | - $cache->setNamespace('ns1'); | ||
271 | - $this->assertFalse($cache->contains('key1')); | ||
272 | - $cache->save('key1', 'test'); | ||
273 | - $this->assertTrue($cache->contains('key1')); | ||
274 | - | ||
275 | - $cache->setNamespace('ns2'); | ||
276 | - $this->assertFalse($cache->contains('key1')); | ||
277 | - $cache->save('key1', 'test'); | ||
278 | - $this->assertTrue($cache->contains('key1')); | ||
279 | - | ||
280 | - $cache->setNamespace('ns1'); | ||
281 | - $this->assertTrue($cache->contains('key1')); | ||
282 | - $cache->deleteAll(); | ||
283 | - $this->assertFalse($cache->contains('key1')); | ||
284 | - | ||
285 | - $cache->setNamespace('ns2'); | ||
286 | - $this->assertTrue($cache->contains('key1')); | ||
287 | - $cache->deleteAll(); | ||
288 | - $this->assertFalse($cache->contains('key1')); | ||
289 | - } | ||
290 | - | ||
291 | - /** | ||
292 | - * @group DCOM-43 | ||
293 | - */ | ||
294 | - public function testGetStats() | ||
295 | - { | ||
296 | - $cache = $this->_getCacheDriver(); | ||
297 | - $stats = $cache->getStats(); | ||
298 | - | ||
299 | - $this->assertArrayHasKey(Cache::STATS_HITS, $stats); | ||
300 | - $this->assertArrayHasKey(Cache::STATS_MISSES, $stats); | ||
301 | - $this->assertArrayHasKey(Cache::STATS_UPTIME, $stats); | ||
302 | - $this->assertArrayHasKey(Cache::STATS_MEMORY_USAGE, $stats); | ||
303 | - $this->assertArrayHasKey(Cache::STATS_MEMORY_AVAILABLE, $stats); | ||
304 | - } | ||
305 | - | ||
306 | - public function testFetchMissShouldReturnFalse() | ||
307 | - { | ||
308 | - $cache = $this->_getCacheDriver(); | ||
309 | - | ||
310 | - /* Ensure that caches return boolean false instead of null on a fetch | ||
311 | - * miss to be compatible with ORM integration. | ||
312 | - */ | ||
313 | - $result = $cache->fetch('nonexistent_key'); | ||
314 | - | ||
315 | - $this->assertFalse($result); | ||
316 | - $this->assertNotNull($result); | ||
317 | - } | ||
318 | - | ||
319 | - /** | ||
320 | - * Check to see that objects are correctly serialized and unserialized by the cache | ||
321 | - * provider. | ||
322 | - */ | ||
323 | - public function testCachedObject() | ||
324 | - { | ||
325 | - $cache = $this->_getCacheDriver(); | ||
326 | - $cache->deleteAll(); | ||
327 | - $obj = new \stdClass(); | ||
328 | - $obj->foo = "bar"; | ||
329 | - $obj2 = new \stdClass(); | ||
330 | - $obj2->bar = "foo"; | ||
331 | - $obj2->obj = $obj; | ||
332 | - $obj->obj2 = $obj2; | ||
333 | - $cache->save("obj", $obj); | ||
334 | - | ||
335 | - $fetched = $cache->fetch("obj"); | ||
336 | - | ||
337 | - $this->assertInstanceOf("stdClass", $obj); | ||
338 | - $this->assertInstanceOf("stdClass", $obj->obj2); | ||
339 | - $this->assertInstanceOf("stdClass", $obj->obj2->obj); | ||
340 | - $this->assertEquals("bar", $fetched->foo); | ||
341 | - $this->assertEquals("foo", $fetched->obj2->bar); | ||
342 | - } | ||
343 | - | ||
344 | - /** | ||
345 | - * Check to see that objects fetched via fetchMultiple are properly unserialized | ||
346 | - */ | ||
347 | - public function testFetchMultipleObjects() | ||
348 | - { | ||
349 | - $cache = $this->_getCacheDriver(); | ||
350 | - $cache->deleteAll(); | ||
351 | - $obj1 = new \stdClass(); | ||
352 | - $obj1->foo = "bar"; | ||
353 | - $cache->save("obj1", $obj1); | ||
354 | - $obj2 = new \stdClass(); | ||
355 | - $obj2->bar = "baz"; | ||
356 | - $cache->save("obj2", $obj2); | ||
357 | - | ||
358 | - $fetched = $cache->fetchMultiple(array("obj1", "obj2")); | ||
359 | - $this->assertInstanceOf("stdClass", $fetched["obj1"]); | ||
360 | - $this->assertInstanceOf("stdClass", $fetched["obj2"]); | ||
361 | - $this->assertEquals("bar", $fetched["obj1"]->foo); | ||
362 | - $this->assertEquals("baz", $fetched["obj2"]->bar); | ||
363 | - } | ||
364 | - | ||
365 | - /** | ||
366 | - * Return whether multiple cache providers share the same storage. | ||
367 | - * | ||
368 | - * This is used for skipping certain tests for shared storage behavior. | ||
369 | - * | ||
370 | - * @return boolean | ||
371 | - */ | ||
372 | - protected function isSharedStorage() | ||
373 | - { | ||
374 | - return true; | ||
375 | - } | ||
376 | - | ||
377 | - /** | ||
378 | - * @return \Doctrine\Common\Cache\CacheProvider | ||
379 | - */ | ||
380 | - abstract protected function _getCacheDriver(); | ||
381 | -} |
-
请 注册 或 登录 后发表评论