Search Results

Search found 310 results on 13 pages for 'memcache'.

Page 2/13 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • memcache is not storing data accross requests

    - by morpheous
    I am new to using memcache, so I may be doing something wrong. I have written a wrapper class around memcache. The wrapper class has only static methods, so is a quasi singleton. The class looks something like this: class myCache { private static $memcache = null; private static $initialized = false; public static function init() { if (self::$initialized) return; self::$memcache = new Memcache(); if (self::configure()) //connects to daemon { self::store('foo', 'bar'); } else throw ConnectionError('I barfed'); } public static function store($key, $data, $flag=MEMCACHE_COMPRESSED, $timeout=86400) { if (self::$memcache->get($key)!== false) return self::$memcache->replace($key, $data, $flag, $timeout); return self::$memcache->set($key, $data, $flag, $timeout); } public static function fetch($key) { return self::$memcache->get($key); } } //in my index.php file, I use the class like this require_once('myCache.php'); myCache::init(); echo 'Stored value is: '. myCache::fetch('foo'); The problem is that the myCache::init() method is being executed in full everytime a page is requested. I then remembered that static variables do not maintain state accross page requests. So I decided instead, to store the flag that indicates whether the server contains the start up data (for our purposes, the variable 'foo', with value 'bar') in memcache itself. Once the status flag is stored in memcache itself, It solves the problem of the initialisation data being loaded for every page request (which quite frankly, defeats the purpose of memcache). However, having solved that problem, when I come to fetch the data in memcache, it is empty. I dont understand whats going on. Can anyone clarify how I can store my data once and retrieve it accross page requests? BTW, (just to clarify), the get/set is working correctly, and if I allow memcache to load the initialisation data for each page request, (which is silly), then the data is available in memcache.

    Read the article

  • Memcache error: Failed reading line from stream (0) Array

    - by daviddripps
    I get some variation of the following error when our server gets put under any significant load. I've Googled for hours about it and tried everything (including upgrading to the latest versions and clean installs). I've read all the posts about it here on SA, but can't figure it out. A lot of people are having the same problem, but no one seems to have a definitive answer. Any help would be greatly appreciated. Thanks in advance. Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Zend_Session::start() - /var/www/trunk/library/Zend/Cache/Backend/Memcached.php(Line:180): Error #8 Memcache::get() [memcache.get]: Server localhost (tcp 11211) failed with: Failed reading line from stream (0) Array We have a copy of our production environment for testing and everything works great until we start load-testing. I think the biggest object stored is about 170KB, but it will probably be about 500KB when all is said and done (well below the 1MB limit). Just FYI: Memcache gets hit about 10-20 times per page load. Here's the memcached settings: PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="64" OPTIONS="" I'm running Memcache 1.4.5 with version 2.2.6 of the PHP-memcache module. PHP is version 5.2.6. memcache details from php -i: memcache memcache support = enabled Active persistent connections = 0 Version = 2.2.6 Revision = $Revision: 303962 $ Directive = Local Value = Master Value memcache.allow_failover = 1 = 1 memcache.chunk_size = 8192 = 8192 memcache.default_port = 11211 = 11211 memcache.default_timeout_ms = 1000 = 1000 memcache.hash_function = crc32 = crc32 memcache.hash_strategy = standard = standard memcache.max_failover_attempts = 20 = 20 Thanks everyone

    Read the article

  • Personal Cache vs Memcache?

    - by Kerry
    I have a personal caching class, which can be seen here ( based off WordPress' ): http://pastie.org/988427 I recently learned about memcache and it said to memcache EVERYTHING: http://highscalability.com/blog/2010/5/17/7-lessons-learned-while-building-reddit-to-270-million-page.html My first thought was just to keep my class with the current functions and make it use memcache instead -- is there any downside to doing this? The main difference I see is that memcache stays on with the server from page to page, while mine is for 1 page load. The problem I see arising, and this is with any system, is that they're dynamic. They change all the time. Whether its search results, visible products, etc. etc. If it's all cached, won't the create a problem? Is there a way to handle this? Obviously if something is bringing back the same results everytime it would be cached, but that's why I was doing it on a per page load basis. I'm sure there is a way to handle this, or is the cache time usually set between 5 minutes and an hour?

    Read the article

  • Idiots guide to app engine and memcache

    - by Gareth Simpson
    I am struggling to find a good tutorial or best practices document for the use of memcache in app engine. I'm pretty happy with it on the level presented in the docs. Get an object by ID, checking memcache first, but I'm unclear on things like: If you cache a query, is there an accepted method for ensuring that the cache is cleared/updated when an object stored in that query is updated. What are the effects of using ReferenceProperties ? If a cache a Foo object with a Bar reference. Is my foo.bar in memcache too and in need of clearing down if it gets updated from some other part of my application. I don't expect answers to this here (unless you are feeling particularly generous!), but pointers to things I could read would be very gratefully received.

    Read the article

  • PHP strange issue with memcache

    - by Industrial
    Hi everyone, I am testing out some memcache code here in PHP: 1: $testInstance = new Memcache; $var = @$testInstance->connect('localhost', 11211); echo $var; // Outputs true no matter if the memcached is running or not. 2: $testInstance = new Memcache; $var = @$testInstance->connect('blablabla', 11211); echo $var; // Outputs false Why on earth is this occuring? I am running WinXP in my development environment and I cant see how the localhost version always returns true no matter if the memcached is running or not. Thanks!

    Read the article

  • Unable to load memcache.so extension ??

    - by billyduc
    I built php from source with configure command : './configure' '--prefix=/usr/local/php-5.2.8' '--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d' '--with-apxs2=/usr/local/httpd/bin/apxs' '--with-mysql=/usr/local/mysql/' '--with-zlib' I installed php memcache extension : wget http://pecl.php.net/get/memcache tar -zxvf memcache-2.2.5.tgz cd memcache-2.2.5 phpize ./configure --enable-memcache make make install I add to my /usr/local/lib/php.in extension=memcache.so Rebooted my apache and run php-m but php seem doesn't load memcache extension I followed this solution from this site http://www.howtoforge.com/forums/showthread.php?t=26554 I added full path extension=/usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so rebooted apache But it didn't load memcache extension ! I google around but the same issue ! How can I load this extension _ _"

    Read the article

  • Error message: uninitialized constant Rails::Initializer::MemCache

    - by tomeara
    I've installed just about every library/gem that I could find for memcached/memcache, but everytime I attempt to run my application I get this error: Error message: uninitialized constant Rails::Initializer::MemCache Exception class: NameError I have tried $ telnet localhost 11211 and memcached is definitely running. Any ideas? (I'm running Apache2/Passenger)

    Read the article

  • Memcache key generation strategy

    - by Maxim Veksler
    Given function f1 which receives n String arguments, would be considered better random key generation strategy for memcache for the scenario described below ? Our Memcache client does internal md5sum hashing on the keys it gets public class MemcacheClient { public Object get(String key) { String md5 = Md5sum.md5(key) // Talk to memcached to get the Serialization... return memcached(md5); } } First option public static String f1(String s1, String s2, String s3, String s4) { String key = s1 + s2 + s3 + s4; return get(key); } Second option /** * Calculate hash from Strings * * @param objects vararg list of String's * * @return calculated md5sum hash */ public static String stringHash(Object... strings) { if(strings == null) throw new NullPointerException("D'oh! Can't calculate hash for null"); MD5 md5sum = new MD5(); // if(prevHash != null) // md5sum.Update(prevHash); for(int i = 0; i < strings.length; i++) { if(strings[i] != null) { md5sum.Update("_" + strings[i] + "_"); // Convert to String... } else { // If object is null, allow minimum entropy by hashing it's position md5sum.Update("_" + i + "_"); } } return md5sum.asHex(); } public static String f1(String s1, String s2, String s3, String s4) { String key = stringHash(s1, s2, s3, s4); return get(key); } Note that the possible problem with the second option is that we are doing second md5sum (in the memcache client) on an already md5sum'ed digest result. Thanks for reading, Maxim.

    Read the article

  • How to troubleshoot memcache set method always fail issue?

    - by Morgan Cheng
    I have XAMPP 1.7.3 installed on Windows 7. The PHP version is 5.3.1. I have successfully installed memcache for win32 from http://www.splinedancer.com/memcached-win32. I got PHP extension php_memcache.dll from http://downloads.php.net/pierre. Restarting apache and checking phpinfo() shows memcache is OK. When I test it with below PHP page. It always fail in set method. <?php $memcache = new Memcache; $memcache->connect('127.0.0.1', 11211) or die ("Could not connect"); $version = $memcache->getVersion(); echo "Server's version: ".$version." \n"; $tmp_object = new stdClass; $tmp_object->str_attr = 'test'; $tmp_object->int_attr = 123; $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server"); echo "Store data in the cache (data will expire in 10 seconds)\n"; $get_result = $memcache->get('key'); echo "Data from the cache: \n" ?> The set method always return false so it constantly output Server's version: Failed to save data at the server I'm stuck. I don't know which way to trouble shoot this issue. Anybody has any idea about possible direction? Thanks.

    Read the article

  • Organizing memcache keys

    - by Industrial
    Hi! Im trying to find a good way to handle memcache keys for storing, retrieving and updating data to/from the cache layer in a more civilized way. Found this pattern, which looks great, but how do I turn it into a functional part of a PHP application? The Identity Map pattern: http://martinfowler.com/eaaCatalog/identityMap.html Thanks!

    Read the article

  • Memcache in python

    - by alex
    I want to memcache an xmldata using python,also needs to update the cache with the refreshed xmldata retreived from webserver,could any one help me with sample code.

    Read the article

  • Consistant hashing with memcache

    - by Industrial
    Hi everyone, I am setting up a new web app that will on the client side feature a multi-memcached server environment for reliability and performance. Would it be wise for us to utilize something like Flexihash to make it better to replicate the data between the memcache servers? Reference: http://github.com/pda/flexihash Thanks!

    Read the article

  • How to replicate data with memcache

    - by Industrial
    Hi everyone, I am trying to find good resources on best practices to data replication across memcache servers. What I want to accomplish is that if one of my servers in my pool goes down, the next server in line already has the info set. I have found "repcached" but since I run a WIN32 test environment, I have been unable to install it. So what's our alternatives on how to replicate data between servers? Thanks,

    Read the article

  • How to do MEMCACHE in WAMP server WINDOWS XP

    - by Kamal Challa
    Hi Iam running WAMP server and just enabled php_memcache extension and have tried the code <?php $memcache = new Memcache; $memcache->connect('localhost', 11211) or die ("Could not connect"); $version = $memcache->getVersion(); echo "Server's version: ".$version."<br/>\n"; $tmp_object = new stdClass; $tmp_object->str_attr = 'test'; $tmp_object->int_attr = 123; $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server"); echo "Store data in the cache (data will expire in 10 seconds)<br/>\n"; $get_result = $memcache->get('key'); echo "Data from the cache:<br/>\n"; var_dump($get_result); ?> and i got the following error Notice: Memcache::connect() [memcache.connect]: Server localhost (tcp 11211) failed with: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060) in C:\wamp\www\memcache\test1.php on line 4 Warning: Memcache::connect() [memcache.connect]: Can't connect to localhost:11211, A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060) in C:\wamp\www\memcache\test1.php on line 4 Could not connect

    Read the article

  • How often does memcache on Google AppEngine lose data?

    - by Freed
    Memcache in general and on AppEngine in specific is unreliable in the sense that my data may be deleted from the cache for whatever reason at any point in time. However, in some cases there might be cases where a small risk may be worth the added performance using memcache could give, such as updating some data in memcache that gets saved periodically to some other, more reliable storage. Are there any numbers from Google that could give me an indication of the actual probability that a memcache entry would be lost from the cache before its expiration time, given that I keep within my quotas? Are there any reasons other than hardware failure and administrative operations such as machines at the data centers being upgraded/moved/replaced that would cause entries to be removed from memcache prematurely?

    Read the article

  • Memcache textual protocol cheatsheet ?

    - by Maxim Veksler
    Memcached interface is implemented using a textual protocol. Sometimes it's very useful to be to fetch data stored on your remote server simply by invoking netcat with some shell kung fu, for example: To download the XML result of your nightly data crunching job you might run something like: echo "get 95ec6c7693ec53771c8a3fb1061562b8" | nc localhost 11211 > console_overview_06_04_2010.xml The interesting part here is get SOME_UNIQUE_KEY which is part of the memcached protocol. What other useful usages can you suggest in regard to the ability to interact with memcached using nothing more then command line tools? Thank you, Maxim.

    Read the article

  • Google App Engine Memcache - Sliding expiration

    - by Keyur
    Is there support for sliding expiration in the GAE MemcacheService? I can do a crude implementation where following every get() I do a put(). This will effectively reset the expiration time but this obviously is not an efficient solution. Any pointers on how I can implement this more efficiently? Thanks, Keyur

    Read the article

  • Faulty to use memcache together with a php web-browser-game in this way?

    - by Crowye
    Background We are currently working on a strategy web-browser game based on php, html and javascript. The plan is to have 10,000+ users playing within the same world. Currently we are using memcached to: store json static data, language files store changeable serialized php class objects (such as armies, inventorys, unit-containers, buildings, etc) In the back we have a mysql server running and holding all the game data aswell. When a object is loaded through our ObjectLoader it loads in this order: checks a static hashmap in the script for the object checks memcache if it has already been loaded into it otherwise loads from database, and saves it into memcache and the static temp hashmap We have built the whole game using a class-object-oriented approach where functionality is always made between objects. Beause of this we think we have managed to get a nice structure, and with the help of memcached we have received good request times from client-server when interacting with the game. I'm aware that memcache is not synchronized, and also is not commonly used for holding a full game in memory. In the beginning after a server's startup the load times when loading objects into memcache for the first time will be high, but after the server's been online for a while and most loads are from memcache, the loads will be well reduced. Currently we are saving changed objects into memcache and database at the same time. Earlier we had an idea to save objects into db only after a certain time or at intervals, but due to risk inconsistency if the memcache/server went down, we skipped it for now. Client requests to server often return object's status simple json-format without changing the object, which in turn is represented in the browser visually with images and javascript. But from time to time depending on when an object was last updated, it updates them with new information (e.g. a build-queue holding planned buildings time-progress is increased, and/or planned-queue-items-array has changed). Questions: Do you see how this could work or are we walking in blindness here? Do you expect us to have a lot of inconsistency issues if someone loads and updates the a memcache objects while someone else does the same? Is it even doable to do it in the way he have done it? Seems to be working fine atm, but so far we have only been 4 people online at the same time.. Is some other cache program more fit for this class-object approach than memcached? Is there any other tips you have for this situation? UPDATE Since it is simply a "normal webpage" (no applet, flash, etc), we are implementing the game so that the server is the only one holding a "real game-state".. the state of the different javascript-objects on the client is more like a approximative version of the server's game state. From time to time and before you do certain things important things, the client's visual state is updated to the server's state (e.g. the client things he can afford a barracks, asks the server to build a barracks, server updates current resources according to income-data on server and then tries to build a barracks or casts an error-message, and then sends the current server-state on resources, buildings back to the client).. It is not a fast-paced game lika real strategy game. More like a quite slow 3-4 months playtime game, where buildings can take +1 minute up to several days to complete.

    Read the article

  • Google App Engine - Memcache - Java version of Python's client.add?

    - by Spines
    The python interface to the memcache has an add method: add(key, value, time=0, min_compress_len=0, namespace=None) Sets a key's value, if and only if the item is not already in memcache. ... The return value is True if added, False on error. So with this you can add an item if it doesn't exist, and see if it previously existed by the return value. The java memcache api equivalent for this doesn't let you know if there was a previous value or not: put(key, value, expiration, MemcacheService.SetPolicy.ADD_ONLY_IF_NOT_PRESENT); MemcacheService.SetPolicy.ADD_ONLY_IF_NOT_PRESENT: add the value if no value with the key, do nothing if the key exists Is there a way to know if a previous value existed or not with the java api? I can't just check with the contains method beforehand, because in between the call to contains and the call to put, another JVM instance could modify the memcache.

    Read the article

  • PHP memcache - check if any server is available in pool?

    - by Industrial
    Hi everyone, I have the following code: $cluster['local'] = array('host' => '192.168.1.1', 'port' => '11211', 'weight' => 50); $cluster['local2'] = array('host' => '192.168.1.2', 'port' => '11211', 'weight' => 50); $this->memcache = new Memcache; foreach ($this->cluster() as $cluster) { $this->memcache->addServer($cluster['host'], $cluster['port'], $this->persistent, $cluster['weight'], 10, 10, TRUE , 'failure' ); } I would like to make a function that checks if any of my servers in my memcache Pool is available. How could this be done?

    Read the article

  • Issues Installing PHP Memcache module

    - by smith
    I am trying to install memcache on my VPS. When I type $ pecl install memcache I get this error checking whether the C compiler works... configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details. ERROR: `/root/tmp/pear/memcache/configure --enable-memcache-session=yes' failed Any ideas what the issue could be?

    Read the article

  • In Google App Engine, what is the simplest way to keep a record of items that you have put into memc

    - by Chris Boesch
    I am starting to use memcache more frequently to avoid having to recalculate things between page requests. When the memcache periodically clears, as it is designed to do, I have to start all over rebuilding various items that I have placed in memcache. What I would like to do is create a very simple model that enables me to periodically save the items that I put into memcache based on the memcache keys that I'm using along with a datetime that is related to the data being memcached. What is the best way to do this? I'm looking for something like this: class MemcacheRecord(db.Model): key = db.StringProperty(required=True) value = #Something that can store whatever memcache can validThru = db.DateTimeProperty(required=True) def set(self, key, value, validThru): #Save a new memcache record newMemcacheRecord = MemcacheRecord(key=key, value=value, validThru=validThru) .. return True # or False def get_latest(self, key): #Get the memcache record with the most recent validThru datetime latestMemcacheRecord = MemcacheRecord.all().order('-validThru').get() return {'validThru':latestMemcacheRecord.validThru, 'value':latestMemcachRecord.value}

    Read the article

  • PHP memcached Fatal error: Class 'Memcache' not found

    - by jpfuentes2
    I've pasted the example from php.net for using memcached in php and I'm getting: Fatal error: Class 'Memcache' not found I have this in my php.ini: [memcache] memcache.hash_strategy = "consistent" memcache.max_failover_attemps = 100 memcache.allow_failover = 1 Here's info from php -i and php -m respectively: php -i | grep -i memcache memcached memcached support = enabled libmemcached version = 0.37 Registered save handlers = files user sqlite memcached php -m | grep -i memcache memcached So php seems to have loaded memcached as a module, and php info says that it is loaded and is using v .37. I have not tried yet via apache, I've only been using this through cli right now. Any thoughts?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >