memcached

Rails: Scheduled task to warm up the cache?

牧云@^-^@ 提交于 2019-12-04 09:37:37
问题 I am using the following to cache a slow loading page using memcached: caches_action :complex_report, :expires_in => 1.day The controller action is protected by Devise authentication. The page currently gets cached the first time a user requests it. Subsequent request that day are then pulled from the cache. The problem with this is that the initial request takes 20-30 seconds to load. Is it possible to populate the cache in advance by way of a scheduled task? Any suggestions much appreciated

memcached client: opening, closing and reusing connections

泄露秘密 提交于 2019-12-04 09:37:31
问题 I have been testing spymemcached and xmemcached clients. I have been trying to find answers in the projects documentation but it is very poor. My questions are regarding opening, closing and reusing the connections. I found this in one document: A client may just close the connection at any moment it no longer needs it. Note, however, that clients are encouraged to cache their connections rather than reopen them every time they need to store or retrieve data. Caching connections will

Memcache-based message queue?

假装没事ソ 提交于 2019-12-04 09:21:46
问题 I'm working on a multiplayer game and it needs a message queue (i.e., messages in, messages out, no duplicates or deleted messages assuming there are no unexpected cache evictions). Here are the memcache-based queues I'm aware of: MemcacheQ: http://memcachedb.org/memcacheq/ Starling: http://rubyforge.org/projects/starling/ Depcached: http://www.marcworrell.com/article-2287-en.html Sparrow: http://code.google.com/p/sparrow/ I learned the concept of the memcache queue from this blog post: All

delete cache by prefix in apc / memcache / eaccelerator

烈酒焚心 提交于 2019-12-04 09:04:23
Let's assume I have these variables saved in apc, memcached and eaccelerator: article_1_0 article_1_1 article_3_2 article_3_3 article_2_4 How can I delete all cached variables that starts with article_3_ (they can reach up to 10000) ? is there any way to list the cached variables ? Arnaud Le Blanc The slow solution For APC: $iterator = new APCIterator('user', '#^article_3_#', APC_ITER_KEY); foreach($iterator as $entry_name) { apc_delete($entry_name); } For eaccelerator: foreach(eaccelerator_list_keys() as $name => $infos) { if (preg_match('#^article_3_#', $name)) { eaccelerator_rm($name); } }

Design pattern for memcached data caching

二次信任 提交于 2019-12-04 08:10:33
问题 It's easy to wrap optional memcached caching around your existing database queries. For example: Old (DB-only): function getX x = get from db return x end New (DB with memcache): function getX x = get from memcache if found return x endif x = get from db set x in memcache return x end The thing is though, that's not always how you want to cache. For instance take the following two queries: -- get all items (recordset) SELECT * FROM items; -- get one item (record) SELECT * FROM items WHERE

Memcached, Locking and Race Conditions

戏子无情 提交于 2019-12-04 08:05:23
问题 We are trying to update memcached objects when we write to the database to avoid having to read them from database after inserts/updates. For our forum post object we have a ViewCount field containing the number of times a post is viewed. We are afraid that we are introducing a race condition by updating the memcached object, as the same post could be viewed at the same time on another server in the farm. Any idea how to deal with these kind of issues - it would seem that some sort of locking

Installed memcached via homebrew, how to start and stop server?

偶尔善良 提交于 2019-12-04 07:28:48
问题 I have memcached installed via homebrew. how do I start/stop the server? Any command-line tools to interact with memcached? does homebrew have a way of removing a package? 回答1: Brew used to have a command brew services (https://thoughtbot.com/blog/starting-and-stopping-background-services-with-homebrew), now deprecated. Instead, to get always-correct advice, run this command: brew info memcached Via telnet: telnet localhost 11211 See also What are some useful tips/tools for monitoring/tuning

Windows下的Memcache安装

让人想犯罪 __ 提交于 2019-12-04 07:07:53
很多phper不知道如何在Windows下搭建Memcache的开发调试环境,最近个人也在研究Memcache,记录下自己安装搭建的过程。 其实我开始研究Memcache的时候并不知道居然还有memcached for Win32这个鸟东西,害得我在CnetOS下折腾1天才搞定,今天突然发现Windows下的Memcache进行开发调试完全没有问题,所以写篇Memcache的文档分享给大家。 Windows下的Memcache安装 : 1. 下载 memcache 的windows稳定版,解压放某个盘下面,比如在c:\memcached 2. 在终端(也即cmd命令界面)下输入 'c:\memcached\memcached.exe -d install' 安装 3. 再输入: 'c:\memcached\memcached.exe -d start' 启动。NOTE: 以后memcached将作为windows的一个服务每次开机时自动启动。这样服务器端已经安装完毕了。 4.下载 php_memcache.dll ,请自己查找对应的php版本的文件 5. 在C:\winnt\php.ini 加入一行 'extension=php_memcache.dll' 6.重新启动Apache,然后查看一下phpinfo,如果有memcache,那么就说明安装成功!

解决Memcached服务经常出现死锁

瘦欲@ 提交于 2019-12-04 07:07:26
我的memcached服务器系统配置及相关编译启动参数如下: 系统硬件:IBM HS20 , 内存8G,无磁盘 操作系统:Centos 5.2 64位 无盘系统,其中4G做为系统内存盘 使用memcached版本:memcached-1.4.10 使用libevent版本:libevent-2.0.15-stable 编译参数:./configure --prefix=/data/update/20111114/memcached --enable-64bit --with-libevent=../libevent-2.0.15 memcached启动参数:/opt/memcache-1.4.10/bin/memcached -vv -o hashpower=24 -p 10091 -U 0 -f 1.001 -n 256 -m 3072 -c 2048 -u appl -d 用gdb -p ,发现memcached 除了网络线程工作正常,其它的四个工作线程都处于死锁状态。 用-vv参数,打开memcached的日志,发现memcached当出现上面的情况前,日志结尾部分总是会报: Hash table expansion starting ,然后就卡在那里了。出错信息如下: Hash table expansion starting <62 get 1379035377@qq

服务器高并发网络设计模型

心不动则不痛 提交于 2019-12-04 07:07:14
Nginx网络模型 一、进程模型 Nginx之所以为广大码农喜爱,除了其高性能外,还有其优雅的系统架构。与 Memcached 的经典多线程模型相比,Nginx是经典的多进程模型。Nginx启动后以daemon的方式在后台运行,后台进程包含一个master进程和多个worker进程,具体如下图: 图1 Nginx多进程模型 master进程主要用来管理worker进程,具体包括如下4个主要功能: (1)接收来自外界的信号。 (2)向各worker进程发送信号。 (3)监控woker进程的运行状态。 (4)当woker进程退出后(异常情况下),会自动重新启动新的woker进程。 woker进程主要用来处理网络事件,各个woker进程之间是对等且相互独立的,它们同等竞争来自客户端的请求,一个请求只可能在一个woker进程中处理,woker进程个数一般设置为机器CPU核数。 二、 进程控制 对Nginx进程的控制主要是通过master进程来做到的,主要有两种方式: (1)手动发送信号 从图1可以看出,master接收信号以管理众woker进程,那么,可以通过kill向master进程发送信号,比如kill -HUP pid用以通知Nginx从容重启。所谓从容重启就是不中断服务:master进程在接收到信号后,会先重新加载配置,然后再启动新进程开始接收新请求