memcached

memcache client缓存节点分配机制和连接读取缓存机制

痞子三分冷 提交于 2019-12-09 10:28:57
//mc client//hashingAlg 默认是0 private final long getHash(String key, Integer hashCode) { if (hashCode != null) { if (hashingAlg == CONSISTENT_HASH) return hashCode.longValue() & 0xffffffffL; else return hashCode.longValue(); } else { switch (hashingAlg) { case NATIVE_HASH:// 0 return (long) key.hashCode(); case OLD_COMPAT_HASH: return origCompatHashingAlg(key); case NEW_COMPAT_HASH: return newCompatHashingAlg(key); case CONSISTENT_HASH: return md5HashingAlg(key); default: // use the native hash as a default hashingAlg = NATIVE_HASH; return (long) key.hashCode(); } } } private boolean set(String

Clearing specific cache in Django

百般思念 提交于 2019-12-09 10:16:46
问题 I am using view caching for a django project. It says the cache uses the URL as the key, so I'm wondering how to clear the cache of one of the keys if a user updates/deletes the object. An example: A user posts a blog post to domain.com/post/1234/ .. If the user edits that, i'd like to delete the cached version of that URL by adding some kind of delete cache command at the end of the view that saves the edited post. I'm using: @cache_page(60 * 60) def post_page(....): If the post.id is 1234,

how to keep caching up to date

有些话、适合烂在心里 提交于 2019-12-08 23:44:18
问题 when memecached or Redis is used for data-storage caching. How is the cache being updated when the value changed? For, example. If I read key1 from cache the first time and it missed, then I pull value1 and put key1=value1 into cache. After that if the value of key1 changed to value2. How is value in cache updated or invalidated? Does that mean whenever there is a change on key1's value. Either the application or database need to check if this key1 is in cache and update it? 回答1: Since you

GAE MemCache behaviour of put() + ADD_ONLY_IF_NOT_PRESENT

喜夏-厌秋 提交于 2019-12-08 23:08:29
The put(...) method of GAE's memcahe API accepts as an argument (in one of it's overloaded implementations) a SetPolicy argument. In the Javadocs here it sais that if you chose "ADD_ONLY_IF_NOT_PRESENT" as policy it's, and I quote: "useful to avoid race conditions." My questions are: what happends with an expired value that was set with the same key? If I add to memcache something like (key=1, value=whatever), then this entry expires, and then I try to add (key=1, value=whatever2) using ADD_ONLY_IF_NOT_PRESENT is whatever2 added to cache or not? What does it mean "useful for race conditions"?

windows - php_memcache.dll - for PHP 5.4

混江龙づ霸主 提交于 2019-12-08 22:41:12
问题 I am borrowing the similar thread that wasn't helpfull for me: php_memcache.dll for PHP 5.3 I setup a server using the latest version of easyPHP for Windows. With it came PHP 5.4. I'm now looking for a memcache.dll file that worked for me before and I get this error "PHP Startup: memcache: Unable t initialize module. Module compiled with module API=20090626 PHP compiled with module api=20100525 These options need to match" Any links to a PHP 5.4 memcache.dll file would be greatly appreciated.

Memcache extension with PHP 7 on CentOS fails to install

家住魔仙堡 提交于 2019-12-08 21:13:13
问题 I'm trying to upgrade a fairly large PHP 5.3 code base to PHP 7. It's hosted on CentOS 6.5, so I want to keep it on that OS. I'm currently doing it on a virgin Vagrant box - I've installed PHP 7 successfully, and all the modules except for Memcache. As root, when I run pecl install memcache it tries to install v2.2.7 but I get a long list of errors and warnings from make . At the end is: make: *** [memcache.lo] Error 1 ERROR: `make' failed According to GoPHP7 it should work, Memcache should

Heroku request timeout when Memcachier reaches cache limit

杀马特。学长 韩版系。学妹 提交于 2019-12-08 19:24:56
问题 I have a Rails app deployed to Heroku using Memcachier (Dalli as client). I'm using the free add-on (which offers a 25 MB cache). We started to receive request timeouts from heroku and, after debugging, we found out that manually flushing Memcachier solved the problem. Timeouts occur when Memcachier reaches levels near its limit, like 20 MB (when limit is 25 MB). Why Memcachier doesn't free cache space with time? Is there any missing configuration to tell Memcachier to flush when cache reach

海量数据库(详解缓存处理方法)

孤者浪人 提交于 2019-12-08 18:42:50
缓存处理大数据 缓存就是将从数据库中获取的结果暂时保存起来在下次使用的时候无需重新到数据库中获取,从而降低数据库的压力。 缓存的使用方式可以分为通过程序直接将数据库数据保存到内存中和使用缓存框架两种方式 它主要用于数据变化不是很频繁的情况。而且如果是定期失效( 数据修改时不失效)的失效机制,实时性要求也不能太高,因为这样缓存中的数据和真实数据可能会不一致。而memcache就是提供缓存的一种缓存框架,可适用多台服务器,也可单服务器 Memcache介绍 MemCache是一个自由、源码开放、高性能、分布式的分布式内存对象缓存系统,用于动态Web应用以减轻数据库的负载。它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高了网站访问的速度。 MemCaChe是一个存储键值对的HashMap,在内存中对任意的数据(比如字符串、对象等)所使用的key-value存储,数据可以来自数据库调用、API调用,或者页面渲染的结果。 大概框架如下图: 同时基于这张图,理一下MemCache一次写缓存的流程: 1、应用程序输入需要写缓存的数据 2、API将Key输入路由算法模块,路由算法根据Key和MemCache集群服务器列表得到一台服务器编号 3、由服务器编号得到MemCache及其的ip地址和端口号 4、API调用通信模块和指定编号的服务器通信,将数据写入该服务器

How often does memcache on Google AppEngine lose data?

有些话、适合烂在心里 提交于 2019-12-08 18:38:03
问题 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

Using cassandra instead of memcache?

狂风中的少年 提交于 2019-12-08 16:42:04
问题 I keep reeding those articles from different sources that big sites are switching from memcache to cassandra. Coming from a mySQL background, I'll get a slight headache trying to see the pros/cons when compared to each other. Can you help me out to learn more about this? 回答1: It would be silly to replace memcached as a cache with Cassandra in most situations. What companies like Digg are doing is, replacing the database+memcached pair with Cassandra: Cassandra provides both durable storage,