Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Problem z cache pod Linuksem, Pod frameworkiem Kohana
MateuszS
post
Post #1





Grupa: Zarejestrowani
Postów: 1 429
Pomógł: 195
Dołączył: 6.10.2008
Skąd: Kraków/Tomaszów Lubelski

Ostrzeżenie: (0%)
-----


Witam.

Mam dziwny problem z keszowaniem pod Linuksem. Zainstalowalem modul memcache zarowno na swoim komputerze z Windowsem jak i na serwerze produkcyjnym z Linuksem. Na obu testowalem keszowanie skryptem:

  1. $memcache = new Memcache;
  2. $memcache->connect('localhost', 11211) or die ("Could not connect");
  3.  
  4. $version = $memcache->getVersion();
  5. echo "Server's version: ".$version."<br/>\n";
  6.  
  7. $tmp_object = array('key' => 'foo');
  8.  
  9. $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
  10. echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";
  11.  
  12. $get_result = $memcache->get('key');
  13. echo "Data from the cache:<br/>\n";
  14.  
  15. var_dump($get_result);


Na obu zdawalo sie dzialac, natomiast gdy chce zapisac swoja tablice w Kohanie za pomoca wrappera:

  1. <?php defined('SYSPATH') or die('No direct script access.');
  2.  
  3. class Model_Cache extends Model {
  4.  
  5. private $memcache;
  6.  
  7. public function debug() {
  8. $memcache = new Memcache;
  9. $memcache->connect('localhost', 11211) or die ("Could not connect");
  10.  
  11. $version = $memcache->getVersion();
  12. print_r("Server's version: ".$version."<br/>\n");
  13.  
  14. $tmp_object = array('key' => 'foo');
  15.  
  16. $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
  17. print_r("Store data in the cache (data will expire in 10 seconds)<br/>\n");
  18.  
  19. $get_result = $memcache->get('key');
  20. print_r("Data from the cache:<br/>\n");
  21.  
  22. var_dump($get_result);
  23. }
  24.  
  25. public function __construct() {
  26. $this->memcache = new Memcache;
  27. $this->memcache->connect('localhost', 11211) or die ("Could not connect");
  28. }
  29.  
  30. public function exists($name) {
  31. if(!$this->get($name)) {
  32. return false;
  33. }
  34. return $this->get($name);
  35. }
  36.  
  37. public function get($name) {
  38. return $this->memcache->get($name);
  39. }
  40.  
  41. public function save($name, $value) {
  42. $this->memcache->set($name, $value, false, 3600*2);
  43. }
  44.  
  45. public function delete_all() {
  46. $this->memcache->flush();
  47. }
  48.  
  49. public function delete($name) {
  50. $this->memcache->delete($name);
  51. }
  52.  
  53.  
  54. }


to nie zapisuje mi mojej zmiennej.

Jakies pomysly skad ta wybiorczosc? Moze gdzies sie ustawia max wielkosc zmiennej? Pozdrawiam

PS Dodam ze modul Cache Kohany rowniez dzialal tylko na localu

Ten post edytował MateuszS 27.01.2017, 10:58:58
Go to the top of the page
+Quote Post
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


Jak odpalisz debug() to nie masz błędów? Bomi się wydaje że brakuje Ci obiektu Memcache
Go to the top of the page
+Quote Post
MateuszS
post
Post #3





Grupa: Zarejestrowani
Postów: 1 429
Pomógł: 195
Dołączył: 6.10.2008
Skąd: Kraków/Tomaszów Lubelski

Ostrzeżenie: (0%)
-----


Cytat(Pyton_000 @ 27.01.2017, 10:57:57 ) *
Jak odpalisz debug() to nie masz błędów? Bomi się wydaje że brakuje Ci obiektu Memcache


Nie mam, wszystko sie dobrze zapisuje. Moze dlatego, ze w debugu mam bardzo mala zmienna? Na obu urzadzeniach odpalilem memcache z parametrem -m 512 czyli 512 megabajtow ale moze gdzies sie jeszcze ustawia max wielkosc zmiennej.

//edit
Ok, wystarczylo zwiekszyc limit na pojedynczy item:

-I 128M

Ten post edytował MateuszS 27.01.2017, 11:03:59
Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Kurcze, co ty tam cachujesz ze musiales ustawic limit 128M?(IMG:style_emoticons/default/questionmark.gif) Nie przedobrzyles lekko?
Go to the top of the page
+Quote Post
MateuszS
post
Post #5





Grupa: Zarejestrowani
Postów: 1 429
Pomógł: 195
Dołączył: 6.10.2008
Skąd: Kraków/Tomaszów Lubelski

Ostrzeżenie: (0%)
-----


Na defaulcie byl chyba jakis chory limit ustawiony w postaci paru mb.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 12:20