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

Commit

Permalink
Merge pull request #16 from tomschlick/analysis-qvk1vz
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
  • Loading branch information
tomschlick committed Sep 11, 2015
2 parents f700448 + 1028e53 commit bcc066d
Show file tree
Hide file tree
Showing 3 changed files with 447 additions and 473 deletions.
41 changes: 21 additions & 20 deletions config/memcached.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}

// --------------------------------------------------------------------------
// Servers
// --------------------------------------------------------------------------
$memcached['servers'] = array(
$memcached['servers'] = [

'default' => array(
'default' => [

'host' => 'localhost',
'port' => '11211',
'weight' => '1',
'persistent' => FALSE
'host' => 'localhost',
'port' => '11211',
'weight' => '1',
'persistent' => false,

)
);
],
];

// --------------------------------------------------------------------------
// Configuration
// --------------------------------------------------------------------------
$memcached['config'] = array(
$memcached['config'] = [

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

// Not necessary if you already are using 'compression'
'auto_compress_tresh' => FALSE, // Controls the minimum value length before attempting to compress automatically.
'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.
// Not necessary if you already are using 'compression'
'auto_compress_tresh' => false, // Controls the minimum value length before attempting to compress automatically.
'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.

'expiration' => 3600, // Default content expiration value (in seconds)
'delete_expiration' => 0 // Default time between the delete command and the actual delete action occurs (in seconds)

);
'expiration' => 3600, // Default content expiration value (in seconds)
'delete_expiration' => 0, // Default time between the delete command and the actual delete action occurs (in seconds)

];

$config['memcached'] = $memcached;

Expand Down
99 changes: 48 additions & 51 deletions controllers/example_memcached.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
<?php
class Example_memcached extends Controller
{
function Example_memcached()
{
parent::Controller();
}

function test()
{
// Load library
$this->load->library('memcached_library');

// Lets try to get the key
$results = $this->memcached_library->get('test');

// If the key does not exist it could mean the key was never set or expired
if (!$results)
{
// Modify this Query to your liking!
$query = $this->db->get('members', 7000);

// Lets store the results
$this->memcached_library->add('test', $query->result());

// Output a basic msg
echo "Alright! Stored some results from the Query... Refresh Your Browser";
}
else
{
// Output
var_dump($results);

// Now let us delete the key for demonstration sake!
$this->memcached_library->delete('test');
}

}

function stats()
{
$this->load->library('memcached_library');

echo $this->memcached_library->getversion();
echo "<br/>";

// We can use any of the following "reset, malloc, maps, cachedump, slabs, items, sizes"
$p = $this->memcached_library->getstats("sizes");

var_dump($p);
}
}

class Example_memcached extends Controller
{
public function Example_memcached()
{
parent::Controller();
}

public function test()
{
// Load library
$this->load->library('memcached_library');

// Lets try to get the key
$results = $this->memcached_library->get('test');

// If the key does not exist it could mean the key was never set or expired
if (!$results) {
// Modify this Query to your liking!
$query = $this->db->get('members', 7000);

// Lets store the results
$this->memcached_library->add('test', $query->result());

// Output a basic msg
echo 'Alright! Stored some results from the Query... Refresh Your Browser';
} else {
// Output
var_dump($results);

// Now let us delete the key for demonstration sake!
$this->memcached_library->delete('test');
}
}

public function stats()
{
$this->load->library('memcached_library');

echo $this->memcached_library->getversion();
echo '<br/>';

// We can use any of the following "reset, malloc, maps, cachedump, slabs, items, sizes"
$p = $this->memcached_library->getstats('sizes');

var_dump($p);
}
}
Loading

0 comments on commit bcc066d

Please sign in to comment.