ITeye博客

随便看看

calmhawk · 共 24 篇文章

redis 事件处理机制及其它

关于redis的事件处理机制,网上有很详细的源码解析了,基于2.0.4的,URL如下: redis源代码分析8–事件处理(上) redis源代码分析8–事件处理(中) redis源代码分析8–事件处理(下) 小总结: 初始化:在redis.c中initServer调用aeCreateEventLoop,并建立了现有唯一的一个time event:serverCron. 使用:在redis.c中main 1) 调用aeSetBeforeSleepProc设置beforeSleep函数,我看的源码是2.2.1的,功能比2.0.4稍作改变,加上了处理之前等待BLPOP的已经unblock的clie…

2011-08-19 17:28 · C/CPP Dev · redis · 评论(0)

Redis 存储结构分析,及哈希相关

Redis 是支持多 key-value 数据库 ( 表 ) 的 , 并用 RedisDb 来表示一个 key-value 数据库 ( 表 ). redisServer 中有一个 redisDb *db; 成员变量 , RedisServer 在初始化时 , 会根据配置文件的 db 数量来创建一个 redisDb 数组 . 客户端在连接后 , 通过 SELECT 指令来选择一个 reidsDb, 如果不指定 , 则缺省是 redisDb 数组的第 1 个 ( 即下标是 0)redisDb. 一个客户端在选择 redisDb 后 , 其后续操作都是在此 redisDb 上进行的 . dictT…

2011-08-18 15:29 · C/CPP Dev · redis · 评论(0)

Redis string的小笔记

数据结构定义: struct sdshdr { long len; long free; char buf[]; }; 1) buf是一个变长数组,指向真正的字符串,非指针*; 2) len存储字符串总长度,保证o(1)的长度获取操作; 3) free存储空闲字符长度. 简短精悍. 新建一个字符串: sds sdsnewlen(const void *init, size_t initlen) { struct sdshdr *sh; sh = zmalloc(sizeof(struct sdshdr)+initlen+1); #ifdef SDS_ABORT_ON_OOM if (sh =…

2011-08-17 17:17 · C/CPP Dev · redis · 评论(0)

Some tips from the architeture of StackOverflow(cont. 1)

Software: 1)HAProxy(load balancer) HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for web sites crawling under very high loads while needing persistence or Layer7 processing. …

2011-08-03 10:46 · HS Server Tips · 评论(0)

android开发随记 - Google Map

Google Map开发教程: http://marakana.com/forums/android/examples/311.html 开发环境Eclipse + ADT, 需要首先下Android SDK并按需求更新. 一般的选择性的会只下Android的package, 要用Google Map, 需要下Third party Add-ons中的Google APIs. 如教程所说,需要申请Google Map的API key. 新建项目时,Build Target需选Google APIs. 运行时报错: Installation error: INSTALL_FAILED_MISS…

2011-06-22 15:21 · Mobile Dev · 评论(0)

拷贝构造函数的相互调用?

G++ error: Error: declaration of xxx shadows parameter Explanation: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.3 Can one constructor of a class call another constructor of the same class to initialize the this object? Nope. Let's work an example. Suppose you want your constructor Foo::…

2011-05-18 18:01 · C/CPP Dev · 评论(0)

Some tips from the architeture of StackOverflow

Definition(from Scaling up vs. Scaling out ): scaling up -- a seriously big iron single server. scaled out -- Hadoop or MapReduce style, across lots and lots of inexpensive servers. Other factors(per year): software licensing: if using all open source software, close to zero. power cost. Scaling up…

2011-03-29 17:12 · HS Server Tips · 评论(0)

DTrace相关

最近在看DTrace,记录下点滴: 文档推荐: 1.入门: DTrace Quick Start Guide: Observing Native and Web Applications in Production (PDF) 2.循序渐进:Learning DTrace Series * Part 1: Introduction (pdf) * * Part 2: Scripts and the D Language (pdf) * * Part 3: Advanced Scripting and Aggregations (pdf) * * Part 4: Solving Everyda…

2011-02-17 11:01 · Performance Tuning · 评论(0)

macro __stringify & __attribute__

这两天听一个老外讲师讲Linux Compile和Debug的Training,看到一些有意思的东西,找了点资料,写出来.算是第一篇有点意义的文章. 这两个宏以前都没见过,据说都是内核里常用的东东,厄,确实接触得少. 首先是__stringify宏: g了一下,找到一篇文章,以下内容都是转载,仅经过验证和整理,粘出内容: 宏定义: 在 linux/stringify.h中 #ifndef __LINUX_STRINGIFY_H #define __LINUX_STRINGIFY_H /* Indirect stringification. Doing two levels allows th…

2010-12-09 17:29 · C/CPP Dev · 评论(0)