Welcome Guest, Not a member yet? Register   Sign In
Memcache in CI
#1

[eluser]hema[/eluser]
Hi All,

Can any one help me how to use memcache in CI. I google it and got some links. But, non of it is working.
#2

[eluser]toopay[/eluser]
Seems you will need this link to get started with memcache.

But, if you let me to give you some suggestions, it will be better if you do some database optimization before talking about an advance MySQL feature, like query cache. Did you try these following optimization, just to mention :

- choosing optimal datatypes
- indexing
- do some normalization and denormalization
- optimize data access, and other query performance optimization

I mean, if we talk, lets say we talk about optimize data access, then the most basic reason a query doesn't perform well is because it's working with too much data. Some queries just have to sift through a lot of data and can't be helped (even if you do implementing some advance technique, like query caching).

My point is, we've found it useful to analyze a poorly performing query in two steps. First, find out whether your application is retrieving more data than you need. Than usually means its accessing too many rows, but maybe also be accessing too many columns. Second, find out wheter the MySQL server is analyzing more rows than it needs.
#3

[eluser]hema[/eluser]
the link u provided gives information on linux version. Can u provide the link for win 7
#4

[eluser]toopay[/eluser]
:-S , http://code.jellycan.com/memcached/
#5

[eluser]hema[/eluser]
iam using this link http://winn.ws/archives/273. But when i tried to execute the file. it is giving me some errors

Message: Trying to get property of non-object

Filename: controllers/baseline.php

Line Number: 20

Can anyone help me in this issue
#6

[eluser]toopay[/eluser]
That article was pointed to some implementation code, AFTER you did success set up the extension.
#7

[eluser]pickupman[/eluser]
[quote author="hema" date="1305289471"]iam using this link http://winn.ws/archives/273. But when i tried to execute the file. it is giving me some errors

Message: Trying to get property of non-object

Filename: controllers/baseline.php

Line Number: 20

Can anyone help me in this issue[/quote]

Usually this error relates to a variable/object not being set and calling a method on it. Would you mind posting your code around those line numbers? I would think if the error is memcache itself, you would receive an error when restarting apache.
#8

[eluser]hema[/eluser]
$this->cache->useMemcache(MEMCACHE_IP, MEMCACHE_PORT);

for this line iam getting error
Message: Use of undefined constant MEMCACHE_IP - assumed 'MEMCACHE_IP'

But when i make this line

$this->cache->useMemcache('MEMCACHE_IP', 'MEMCACHE_PORT');

it is not giving me error. Is this correct way to do.

this is the code iam having

$this->cache->useMemcache('MEMCACHE_IP', 'MEMCACHE_PORT');
$data = array('name' => 'Greg', 'id' => 190);
$this->cache->save($data["id"].'_user',$data,NULL,3600);
// Data above saved to memcache

$this->cache->useFile();
$data = array('name' => 'Greg', 'id' => 190);
$this->cache->save($data["id"].'_user',$data,NULL,3600);
// Data above saved to file.
//Now lets retrieve the data from the cache.
$this->cache->get(KEY);

// For the above line i am getting error
//Message: Use of undefined constant KEY - assumed 'KEY'

// In my case above...

$user = $this->cache->get('190_user');
echo $user->id;
echo $user->name;

For the last two lines iam getting this error

Message: Trying to get property of non-object
#9

[eluser]pickupman[/eluser]
All caps denotes a defined variable. Putting it in quotes makes it a string. You need something like
Code:
//In application/config/constants.php
define('MEMCACHE_IP', '127.0.0.1');
define('MEMCACHE_PORT', '11211');

//Then continue to use:
$this->cache->useMemcache(MEMCACHE_IP, MEMCACHE_PORT);

Constants are written in all caps. Kind of like creating a variable with $, but as the name states, constants don't change hence the different syntax.
#10

[eluser]hema[/eluser]
What about the key iam getting
$key = $this->cache->get(KEY); // giving me error Message: Use of undefined constant KEY - assumed 'KEY'

should this be also defined or it should be like that only




Theme © iAndrew 2016 - Forum software by © MyBB