Passed
Pull Request — master (#852)
by
unknown
03:03
created
lib/Phpfastcache/Drivers/Zenddisk/Driver.php 1 patch
Switch Indentation   -66 removed lines patch added patch discarded remove patch
@@ -36,69 +36,3 @@
 block discarded – undo
36 36
     public function getHelp(): string
37 37
     {
38 38
         return <<<'HELP'
39
-            <p>
40
-            This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server
41
-            </p>
42
-            HELP;
43
-    }
44
-
45
-    public function getStats(): DriverStatistic
46
-    {
47
-        $stat = new DriverStatistic();
48
-        $stat->setInfo('[ZendDisk] A void info string')
49
-            ->setSize(0)
50
-            ->setData(implode(', ', array_keys($this->itemInstances)))
51
-            ->setRawData(false);
52
-
53
-        return $stat;
54
-    }
55
-
56
-    protected function driverConnect(): bool
57
-    {
58
-        return true;
59
-    }
60
-
61
-    protected function driverRead(ExtendedCacheItemInterface $item): ?array
62
-    {
63
-        $data = zend_disk_cache_fetch($item->getKey());
64
-        if (false === $data) {
65
-            return null;
66
-        }
67
-
68
-        return $data;
69
-    }
70
-
71
-    /**
72
-     * @throws PhpfastcacheInvalidArgumentException
73
-     *
74
-     * @return mixed
75
-     */
76
-    protected function driverWrite(ExtendedCacheItemInterface $item): bool
77
-    {
78
-        $this->assertCacheItemType($item, Item::class);
79
-
80
-        $ttl = $item->getExpirationDate()->getTimestamp() - time();
81
-
82
-        return zend_disk_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0));
83
-    }
84
-
85
-    /**
86
-     * @throws PhpfastcacheInvalidArgumentException
87
-     */
88
-    protected function driverDelete(ExtendedCacheItemInterface $item): bool
89
-    {
90
-        $this->assertCacheItemType($item, Item::class);
91
-
92
-        return (bool) zend_disk_cache_delete($item->getKey());
93
-    }
94
-
95
-    protected function driverClear(): bool
96
-    {
97
-        return @zend_disk_cache_clear();
98
-    }
99
-
100
-    public function getConfig(): Config
101
-    {
102
-        return $this->config;
103
-    }
104
-}
Please login to merge, or discard this patch.
lib/Phpfastcache/Drivers/Zendshm/Driver.php 1 patch
Switch Indentation   -66 removed lines patch added patch discarded remove patch
@@ -36,69 +36,3 @@
 block discarded – undo
36 36
     public function getHelp(): string
37 37
     {
38 38
         return <<<'HELP'
39
-            <p>
40
-            This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server
41
-            </p>
42
-            HELP;
43
-    }
44
-
45
-    public function getStats(): DriverStatistic
46
-    {
47
-        $stats = (array) zend_shm_cache_info();
48
-
49
-        return (new DriverStatistic())
50
-            ->setData(implode(', ', array_keys($this->itemInstances)))
51
-            ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total']))
52
-            ->setRawData($stats)
53
-            ->setSize($stats['memory_total']);
54
-    }
55
-
56
-    protected function driverConnect(): bool
57
-    {
58
-        return true;
59
-    }
60
-
61
-    protected function driverRead(ExtendedCacheItemInterface $item): ?array
62
-    {
63
-        $data = zend_shm_cache_fetch($item->getKey());
64
-        if (false === $data) {
65
-            return null;
66
-        }
67
-
68
-        return $data;
69
-    }
70
-
71
-    /**
72
-     * @throws PhpfastcacheInvalidArgumentException
73
-     *
74
-     * @return mixed
75
-     */
76
-    protected function driverWrite(ExtendedCacheItemInterface $item): bool
77
-    {
78
-        $this->assertCacheItemType($item, Item::class);
79
-
80
-        $ttl = $item->getExpirationDate()->getTimestamp() - time();
81
-
82
-        return zend_shm_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0));
83
-    }
84
-
85
-    /**
86
-     * @throws PhpfastcacheInvalidArgumentException
87
-     */
88
-    protected function driverDelete(ExtendedCacheItemInterface $item): bool
89
-    {
90
-        $this->assertCacheItemType($item, Item::class);
91
-
92
-        return (bool) zend_shm_cache_delete($item->getKey());
93
-    }
94
-
95
-    protected function driverClear(): bool
96
-    {
97
-        return @zend_shm_cache_clear();
98
-    }
99
-
100
-    public function getConfig(): Config
101
-    {
102
-        return $this->config;
103
-    }
104
-}
Please login to merge, or discard this patch.
lib/Phpfastcache/Drivers/Predis/Driver.php 1 patch
Switch Indentation   -128 removed lines patch added patch discarded remove patch
@@ -45,131 +45,3 @@
 block discarded – undo
45 45
     public function getHelp(): string
46 46
     {
47 47
         return <<<'HELP'
48
-            <p>
49
-            To install the Predis library via Composer:
50
-            <code>composer require "predis/predis" "~1.1.0"</code>
51
-            </p>
52
-            HELP;
53
-    }
54
-
55
-    public function getStats(): DriverStatistic
56
-    {
57
-        $info = $this->instance->info();
58
-        $size = ($info['Memory']['used_memory'] ?? 0);
59
-        $version = ($info['Server']['redis_version'] ?? 0);
60
-        $date = (isset($info['Server']['uptime_in_seconds']) ? (new DateTimeImmutable())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date');
61
-
62
-        return (new DriverStatistic())
63
-            ->setData(implode(', ', array_keys($this->itemInstances)))
64
-            ->setRawData($info)
65
-            ->setSize((int) $size)
66
-            ->setInfo(
67
-                sprintf(
68
-                    "The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.",
69
-                    $version,
70
-                    $date->format(\DATE_RFC2822)
71
-                )
72
-            );
73
-    }
74
-
75
-    /**
76
-     * @throws PhpfastcacheDriverException
77
-     * @throws PhpfastcacheLogicException
78
-     */
79
-    protected function driverConnect(): bool
80
-    {
81
-        /*
82
-         * In case of an user-provided
83
-         * Predis client just return here
84
-         */
85
-        if ($this->getConfig()->getPredisClient() instanceof PredisClient) {
86
-            $this->instance = $this->getConfig()->getPredisClient();
87
-            if (!$this->instance->isConnected()) {
88
-                $this->instance->connect();
89
-            }
90
-
91
-            return true;
92
-        }
93
-
94
-        $options = [];
95
-
96
-        if ($this->getConfig()->getOptPrefix()) {
97
-            $options['prefix'] = $this->getConfig()->getOptPrefix();
98
-        }
99
-
100
-        if (!empty($this->getConfig()->getPath())) {
101
-            $this->instance = new PredisClient(
102
-                [
103
-                    'scheme' => $this->getConfig()->getScheme(),
104
-                    'persistent' => $this->getConfig()->isPersistent(),
105
-                    'timeout' => $this->getConfig()->getTimeout(),
106
-                    'path' => $this->getConfig()->getPath(),
107
-                ],
108
-                $options
109
-            );
110
-        } else {
111
-            $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray(), $options);
112
-        }
113
-
114
-        try {
115
-            $this->instance->connect();
116
-        } catch (PredisConnectionException $e) {
117
-            throw new PhpfastcacheDriverException('Failed to connect to predis server. Check the Predis documentation: https://github.com/nrk/predis/tree/v1.1#how-to-install-and-use-predis', 0, $e);
118
-        }
119
-
120
-        return true;
121
-    }
122
-
123
-    protected function driverRead(ExtendedCacheItemInterface $item): ?array
124
-    {
125
-        $val = $this->instance->get($item->getKey());
126
-        if (false == $val) {
127
-            return null;
128
-        }
129
-
130
-        return $this->decode($val);
131
-    }
132
-
133
-    /**
134
-     * @throws PhpfastcacheInvalidArgumentException
135
-     * @throws PhpfastcacheLogicException
136
-     *
137
-     * @return mixed
138
-     */
139
-    protected function driverWrite(ExtendedCacheItemInterface $item): bool
140
-    {
141
-        $this->assertCacheItemType($item, Item::class);
142
-
143
-        $ttl = $item->getExpirationDate()->getTimestamp() - time();
144
-
145
-        /*
146
-         * @see https://redis.io/commands/setex
147
-         * @see https://redis.io/commands/expire
148
-         */
149
-        if ($ttl <= 0) {
150
-            return (bool) $this->instance->expire($item->getKey(), 0);
151
-        }
152
-
153
-        return 'OK' === $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload();
154
-    }
155
-
156
-    /**
157
-     * @throws PhpfastcacheInvalidArgumentException
158
-     */
159
-    protected function driverDelete(ExtendedCacheItemInterface $item): bool
160
-    {
161
-        $this->assertCacheItemType($item, Item::class);
162
-
163
-        return (bool) $this->instance->del([$item->getKey()]);
164
-    }
165
-
166
-    protected function driverClear(): bool
167
-    {
168
-        return 'OK' === $this->instance->flushdb()->getPayload();
169
-    }
170
-
171
-    public function getConfig(): Config
172
-    {
173
-        return $this->config;
174
-    }
175
-}
Please login to merge, or discard this patch.