Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Commit bcc066d

Browse files
committed
Merge pull request #16 from tomschlick/analysis-qvk1vz
Applied fixes from StyleCI
2 parents f700448 + 1028e53 commit bcc066d

File tree

3 files changed

+447
-473
lines changed

3 files changed

+447
-473
lines changed

config/memcached.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
11
<?php
2-
if (!defined('BASEPATH')) exit('No direct script access allowed');
32

3+
if (!defined('BASEPATH')) {
4+
exit('No direct script access allowed');
5+
}
46

57
// --------------------------------------------------------------------------
68
// Servers
79
// --------------------------------------------------------------------------
8-
$memcached['servers'] = array(
10+
$memcached['servers'] = [
911

10-
'default' => array(
12+
'default' => [
1113

12-
'host' => 'localhost',
13-
'port' => '11211',
14-
'weight' => '1',
15-
'persistent' => FALSE
14+
'host' => 'localhost',
15+
'port' => '11211',
16+
'weight' => '1',
17+
'persistent' => false,
1618

17-
)
18-
);
19+
],
20+
];
1921

2022
// --------------------------------------------------------------------------
2123
// Configuration
2224
// --------------------------------------------------------------------------
23-
$memcached['config'] = array(
25+
$memcached['config'] = [
2426

25-
'engine' => 'Memcached', // Set which caching engine you are using. Acceptable values: Memcached or Memcache
26-
'prefix' => '', // Prefixes every key value (useful for multi environment setups)
27-
'compression' => FALSE, // Default: FALSE or MEMCACHE_COMPRESSED Compression Method (Memcache only).
27+
'engine' => 'Memcached', // Set which caching engine you are using. Acceptable values: Memcached or Memcache
28+
'prefix' => '', // Prefixes every key value (useful for multi environment setups)
29+
'compression' => false, // Default: FALSE or MEMCACHE_COMPRESSED Compression Method (Memcache only).
2830

29-
// Not necessary if you already are using 'compression'
30-
'auto_compress_tresh' => FALSE, // Controls the minimum value length before attempting to compress automatically.
31-
'auto_compress_savings' => 0.2, // Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1.
31+
// Not necessary if you already are using 'compression'
32+
'auto_compress_tresh' => false, // Controls the minimum value length before attempting to compress automatically.
33+
'auto_compress_savings' => 0.2, // Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1.
3234

33-
'expiration' => 3600, // Default content expiration value (in seconds)
34-
'delete_expiration' => 0 // Default time between the delete command and the actual delete action occurs (in seconds)
35-
36-
);
35+
'expiration' => 3600, // Default content expiration value (in seconds)
36+
'delete_expiration' => 0, // Default time between the delete command and the actual delete action occurs (in seconds)
3737

38+
];
3839

3940
$config['memcached'] = $memcached;
4041

controllers/example_memcached.php

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
11
<?php
2-
class Example_memcached extends Controller
3-
{
4-
function Example_memcached()
5-
{
6-
parent::Controller();
7-
}
8-
9-
function test()
10-
{
11-
// Load library
12-
$this->load->library('memcached_library');
13-
14-
// Lets try to get the key
15-
$results = $this->memcached_library->get('test');
16-
17-
// If the key does not exist it could mean the key was never set or expired
18-
if (!$results)
19-
{
20-
// Modify this Query to your liking!
21-
$query = $this->db->get('members', 7000);
22-
23-
// Lets store the results
24-
$this->memcached_library->add('test', $query->result());
25-
26-
// Output a basic msg
27-
echo "Alright! Stored some results from the Query... Refresh Your Browser";
28-
}
29-
else
30-
{
31-
// Output
32-
var_dump($results);
33-
34-
// Now let us delete the key for demonstration sake!
35-
$this->memcached_library->delete('test');
36-
}
37-
38-
}
39-
40-
function stats()
41-
{
42-
$this->load->library('memcached_library');
43-
44-
echo $this->memcached_library->getversion();
45-
echo "<br/>";
46-
47-
// We can use any of the following "reset, malloc, maps, cachedump, slabs, items, sizes"
48-
$p = $this->memcached_library->getstats("sizes");
49-
50-
var_dump($p);
51-
}
52-
}
2+
3+
class Example_memcached extends Controller
4+
{
5+
public function Example_memcached()
6+
{
7+
parent::Controller();
8+
}
9+
10+
public function test()
11+
{
12+
// Load library
13+
$this->load->library('memcached_library');
14+
15+
// Lets try to get the key
16+
$results = $this->memcached_library->get('test');
17+
18+
// If the key does not exist it could mean the key was never set or expired
19+
if (!$results) {
20+
// Modify this Query to your liking!
21+
$query = $this->db->get('members', 7000);
22+
23+
// Lets store the results
24+
$this->memcached_library->add('test', $query->result());
25+
26+
// Output a basic msg
27+
echo 'Alright! Stored some results from the Query... Refresh Your Browser';
28+
} else {
29+
// Output
30+
var_dump($results);
31+
32+
// Now let us delete the key for demonstration sake!
33+
$this->memcached_library->delete('test');
34+
}
35+
}
36+
37+
public function stats()
38+
{
39+
$this->load->library('memcached_library');
40+
41+
echo $this->memcached_library->getversion();
42+
echo '<br/>';
43+
44+
// We can use any of the following "reset, malloc, maps, cachedump, slabs, items, sizes"
45+
$p = $this->memcached_library->getstats('sizes');
46+
47+
var_dump($p);
48+
}
49+
}

0 commit comments

Comments
 (0)