Permalink
Browse files

Using doctrine/cache.

  • Loading branch information...
1 parent f5ce8b5 commit 47c94b0fa81e3934751040ae9f1b1db9efa1ddce @overtrue committed Jan 7, 2016
Showing with 141 additions and 345 deletions.
  1. +1 −2 .php_cs
  2. +2 −1 composer.json
  3. +2 −1 src/Broadcast/Broadcast.php
  4. +2 −1 src/Broadcast/MessageBuilder.php
  5. +2 −1 src/Broadcast/Transformer.php
  6. +0 −57 src/Cache/Adapters/AdapterInterface.php
  7. +0 −95 src/Cache/Adapters/FileAdapter.php
  8. +0 −122 src/Cache/Manager.php
  9. +0 −24 src/Cache/composer.json
  10. +1 −0 src/Core/AbstractAPI.php
  11. +22 −8 src/Core/AccessToken.php
  12. +1 −0 src/Core/Exception.php
  13. +1 −0 src/Core/Exceptions/FaultException.php
  14. +1 −0 src/Core/Exceptions/HttpException.php
  15. +1 −0 src/Core/Exceptions/InvalidArgumentException.php
  16. +1 −0 src/Core/Exceptions/InvalidConfigException.php
  17. +1 −0 src/Core/Exceptions/RuntimeException.php
  18. +1 −0 src/Core/Exceptions/UnboundServiceException.php
  19. +1 −0 src/Core/Http.php
  20. +1 −1 src/Core/composer.json
  21. +1 −0 src/Device/DeviceHttpException.php
  22. +1 −0 src/Encryption/EncryptionException.php
  23. +1 −0 src/Encryption/Encryptor.php
  24. +3 −2 src/Foundation/Application.php
  25. +1 −0 src/Foundation/Config.php
  26. +1 −0 src/Foundation/ServiceProviders/BroadcastServiceProvider.php
  27. +1 −0 src/Foundation/ServiceProviders/JsServiceProvider.php
  28. +1 −0 src/Foundation/ServiceProviders/MaterialServiceProvider.php
  29. +1 −0 src/Foundation/ServiceProviders/MenuServiceProvider.php
  30. +1 −0 src/Foundation/ServiceProviders/NoticeServiceProvider.php
  31. +1 −0 src/Foundation/ServiceProviders/OAuthServiceProvider.php
  32. +1 −0 src/Foundation/ServiceProviders/POIServiceProvider.php
  33. +1 −0 src/Foundation/ServiceProviders/PaymentServiceProvider.php
  34. +1 −0 src/Foundation/ServiceProviders/QRCodeServiceProvider.php
  35. +1 −0 src/Foundation/ServiceProviders/SemanticServiceProvider.php
  36. +1 −0 src/Foundation/ServiceProviders/ServerServiceProvider.php
  37. +1 −0 src/Foundation/ServiceProviders/StaffServiceProvider.php
  38. +1 −0 src/Foundation/ServiceProviders/StatsServiceProvider.php
  39. +1 −0 src/Foundation/ServiceProviders/UrlServiceProvider.php
  40. +1 −0 src/Foundation/ServiceProviders/UserServiceProvider.php
  41. +8 −7 src/Js/Js.php
  42. +1 −0 src/Material/Material.php
  43. +1 −0 src/Material/Temporary.php
  44. +1 −0 src/Menu/Menu.php
  45. +1 −0 src/Message/AbstractMessage.php
  46. +1 −0 src/Message/Article.php
  47. +1 −0 src/Message/Image.php
  48. +1 −0 src/Message/Link.php
  49. +1 −0 src/Message/Location.php
  50. +1 −0 src/Message/Material.php
  51. +1 −0 src/Message/Music.php
  52. +2 −1 src/Message/News.php
  53. +1 −0 src/Message/Raw.php
  54. +1 −0 src/Message/ShortVideo.php
  55. +1 −0 src/Message/Text.php
  56. +1 −0 src/Message/Transfer.php
  57. +1 −0 src/Message/Video.php
  58. +1 −0 src/Message/Voice.php
  59. +1 −0 src/Notice/Notice.php
  60. +1 −0 src/POI/POI.php
  61. +1 −0 src/Payment/API.php
  62. +1 −0 src/Payment/Merchant.php
  63. +1 −0 src/Payment/Order.php
  64. +1 −0 src/Payment/Payment.php
  65. +1 −0 src/Payment/helpers.php
  66. +1 −0 src/QRCode/QRCode.php
  67. +1 −0 src/Semantic/Semantic.php
  68. +1 −0 src/Server/BadRequestException.php
  69. +1 −0 src/Server/Guard.php
  70. +1 −0 src/Server/Transformer.php
  71. +1 −0 src/Staff/MessageBuilder.php
  72. +1 −0 src/Staff/Staff.php
  73. +1 −0 src/Staff/Transformer.php
  74. +1 −0 src/Stats/Stats.php
  75. +1 −0 src/Store/Store.php
  76. +1 −0 src/Support/Arr.php
  77. +1 −0 src/Support/Attribute.php
  78. +1 −0 src/Support/Collection.php
  79. +1 −0 src/Support/File.php
  80. +1 −0 src/Support/Log.php
  81. +1 −0 src/Support/Str.php
  82. +1 −0 src/Support/Url.php
  83. +1 −0 src/Support/XML.php
  84. +1 −0 src/Url/Url.php
  85. +1 −0 src/User/Group.php
  86. +1 −0 src/User/User.php
  87. +7 −7 tests/Broadcast/BroadcastBroadcastTest.php
  88. +7 −7 tests/Core/CoreAccessTokenTest.php
  89. +10 −8 tests/Js/JsJsTest.php
View
@@ -23,7 +23,6 @@ return Symfony\CS\Config\Config::create()
))
->finder(
Symfony\CS\Finder\DefaultFinder::create()
- ->exclude('vendor')
- ->in(__DIR__)
+ ->in(__DIR__.'/src')
)
;
View
@@ -20,7 +20,8 @@
"ext-openssl": "*",
"pimple/pimple": "~3.0",
"monolog/monolog": "^1.17",
- "overtrue/socialite": "^1.0"
+ "overtrue/socialite": "^1.0",
+ "doctrine/cache": "~1.4"
},
"replace":{
"easywechat/core":"self.version",
@@ -1,7 +1,7 @@
<?php
/*
- * This file is part of the EasyWeChat.
+ * This file is part of the overtrue/wechat.
*
* (c) overtrue <i@overtrue.me>
*
@@ -18,6 +18,7 @@
* @link https://github.com/overtrue
* @link http://overtrue.me
*/
+
namespace EasyWeChat\Broadcast;
use EasyWeChat\Core\AbstractAPI;
@@ -1,7 +1,7 @@
<?php
/*
- * This file is part of the EasyWeChat.
+ * This file is part of the overtrue/wechat.
*
* (c) overtrue <i@overtrue.me>
*
@@ -18,6 +18,7 @@
* @link https://github.com/overtrue
* @link http://overtrue.me
*/
+
namespace EasyWeChat\Broadcast;
use EasyWeChat\Core\Exceptions\InvalidArgumentException;
@@ -1,7 +1,7 @@
<?php
/*
- * This file is part of the EasyWeChat.
+ * This file is part of the overtrue/wechat.
*
* (c) overtrue <i@overtrue.me>
*
@@ -18,6 +18,7 @@
* @link https://github.com/overtrue
* @link http://overtrue.me
*/
+
namespace EasyWeChat\Broadcast;
use EasyWeChat\Core\Exceptions\InvalidArgumentException;
@@ -1,57 +0,0 @@
-<?php
-
-/*
- * This file is part of the overtrue/wechat.
- *
- * (c) overtrue <i@overtrue.me>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-/**
- * AdapterInterface.php.
- *
- * @author overtrue <i@overtrue.me>
- * @copyright 2015 overtrue <i@overtrue.me>
- *
- * @link https://github.com/overtrue
- * @link http://overtrue.me
- */
-namespace EasyWeChat\Cache\Adapters;
-
-/**
- * Interface AdapterInterface.
- */
-interface AdapterInterface
-{
- /**
- * Set app id.
- *
- * @param string $appId
- *
- * @return AdapterInterface
- */
- public function setAppId($appId);
-
- /**
- * Get cache content.
- *
- * @param string $key
- * @param mixed|null $default
- *
- * @return string
- */
- public function get($key, $default = null);
-
- /**
- * Set cache content.
- *
- * @param string $key
- * @param string $value
- * @param int $lifetime
- *
- * @return int
- */
- public function set($key, $value, $lifetime = 7200);
-}
@@ -1,95 +0,0 @@
-<?php
-
-/*
- * This file is part of the overtrue/wechat.
- *
- * (c) overtrue <i@overtrue.me>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-/**
- * FileAdapter.php.
- *
- * @author overtrue <i@overtrue.me>
- * @copyright 2015 overtrue <i@overtrue.me>
- *
- * @link https://github.com/overtrue
- * @link http://overtrue.me
- */
-namespace EasyWeChat\Cache\Adapters;
-
-use EasyWeChat\Core\Exceptions\RuntimeException;
-
-/**
- * Class FileAdapter.
- */
-class FileAdapter
-{
- /**
- * appId.
- *
- * @var string
- */
- protected $appId;
-
- /**
- * {@inheritdoc}
- */
- public function setAppId($appId)
- {
- $this->appId = $appId;
-
- return $this;
- }
-
- /**
- * {@inheritdoc}
- */
- public function set($key, $value, $lifetime = 7200)
- {
- $data = [
- 'data' => $value,
- 'expired_at' => time() + $lifetime - 100, //XXX: -100 will be safe.
- ];
-
- if (!$length = file_put_contents($this->getCacheFile($key), serialize($data))) {
- throw new RuntimeException('Access toekn cache failed.');
- }
-
- return $length;
- }
-
- /**
- * {@inheritdoc}
- */
- public function get($key, $default = null)
- {
- $return = null;
-
- $file = $this->getCacheFile($key);
-
- if (file_exists($file) && ($data = unserialize(file_get_contents($file)))) {
- $return = $data['expired_at'] > time() ? $data['data'] : null;
- }
-
- if (!$return) {
- $return = is_callable($default) ? $default($key) : $default;
- }
-
- return $return;
- }
-
- /**
- * Get filename of cache.
- *
- * @param string $key
- *
- * @return string
- */
- protected function getCacheFile($key)
- {
- return sys_get_temp_dir().DIRECTORY_SEPARATOR.md5($this->appId.$key);
- }
-}
View
@@ -1,122 +0,0 @@
-<?php
-
-/*
- * This file is part of the overtrue/wechat.
- *
- * (c) overtrue <i@overtrue.me>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-/**
- * Manager.php.
- *
- * @author overtrue <i@overtrue.me>
- * @copyright 2015 overtrue <i@overtrue.me>
- *
- * @link https://github.com/overtrue
- * @link http://overtrue.me
- */
-namespace EasyWeChat\Cache;
-
-use EasyWeChat\Cache\Adapters\AdapterInterface;
-use EasyWeChat\Cache\Adapters\FileAdapter;
-
-/**
- * Class Manager.
- *
- * @method get($key, $default)
- * @method set($key, $value, $lifetime = 7200)
- */
-class Manager
-{
- /**
- * Cache adapter.
- *
- * @var AdapterInterface
- */
- protected $adapter;
-
- /**
- * App id.
- *
- * @var string
- */
- protected $appId;
-
- /**
- * Constructor.
- *
- * @param AdapterInterface $adapter
- */
- public function __construct(AdapterInterface $adapter = null)
- {
- $this->adapter = $adapter;
- }
-
- /**
- * Set cache adapter.
- *
- * @param AdapterInterface $adapter
- *
- * @return Manager
- */
- public function setAdapter(AdapterInterface $adapter)
- {
- $this->adapter = $adapter;
-
- return $this;
- }
-
- /**
- * Return current cache adapter.
- *
- * @return AdapterInterface
- */
- public function getAdapter()
- {
- return $this->adapter ? $this->adapter : $this->adapter = $this->makeAdapter();
- }
-
- /**
- * Return cache adapter.
- *
- * @return AdapterInterface
- */
- public function makeAdapter()
- {
- if ($this->adapter) {
- return $this->adapter;
- }
-
- return $this->makeDefaultAdapter();
- }
-
- /**
- * Return default cache adapter instance.
- *
- * @return AdapterInterface
- */
- protected function makeDefaultAdapter()
- {
- $adapter = new FileAdapter();
-
- $adapter->setAppId($this->appId);
-
- return $adapter;
- }
-
- /**
- * Magic call.
- *
- * @param string $method
- * @param array $args
- *
- * @return mixed
- */
- public function __call($method, $args)
- {
- return call_user_func_array([$this->getAdapter(), $method], $args);
- }
-}
@@ -1,24 +0,0 @@
-{
- "name": "easywechat/cache",
- "description": "cache module for EasyWeChat SDK.",
- "keywords": ["wechat", "weixin", "SDK", "cache", "easywechat"],
- "license": "MIT",
- "authors": [
- {
- "name": "overtrue",
- "email": "anzhengchao@gmail.com"
- }
- ],
- "autoload": {
- "psr-4": {
- "EasyWeChat\\Cache\\": "."
- }
- },
- "minimum-stability":"dev",
- "require-dev": {
- "phpunit/phpunit": "4.8.*",
- "mockery/mockery": "^1.0@dev"
- },
- "require": {
- }
-}
@@ -19,6 +19,7 @@
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
+
namespace EasyWeChat\Core;
use EasyWeChat\Core\Exceptions\HttpException;
Oops, something went wrong.

0 comments on commit 47c94b0

Please sign in to comment.