Esempio n. 1
0
void gen_secs_hot_subjects_xml(int mytype)
{
	int i;

	for(i=0; i<SECNUM; i++){
		gen_sec_hot_subjects_xml(mytype, i);
	}
}
Esempio n. 2
0
void gen_secs_hot_subjects_xml(int mytype)
{
    int i;

    for (i=0; i<SECNUM; i++) {
        gen_sec_hot_subjects_xml(mytype, i);
    }

#ifdef REDIS
    redisContext *redis = redisConnect("127.0.0.1", 6379);
    const char *pattern = "stat:%s_sec%d:%s";
    char key[128];
    char value[512];
    const char *argv[3] = { "RPUSH", key, value };

#define RPUSH(ikey,itype,ivalue) {\
    snprintf(key, 128, pattern, myfile[mytype], secid, ikey);\
    snprintf(value, 512, itype, ivalue);\
    redisAppendCommandArgv(redis, 3, argv, NULL);\
}

#define DEL(ikey) {\
    snprintf(key, 128, pattern, myfile[mytype], secid, ikey);\
    snprintf(value, 512, "DEL %s", key);\
    redisAppendCommand(redis, value);\
}

    int secid;
    for (secid = 0; secid < SECNUM; ++secid) {
        DEL("title");
        DEL("author");
        DEL("board");
        DEL("replies");
        DEL("time");
        DEL("id");
        for (i = 0; i < sectopnum[secid]; i++) {
            RPUSH("title"   , "%s"  , sectop[secid][i].title);
            RPUSH("author"  , "%s"  , sectop[secid][i].userid);
            RPUSH("board"   , "%s"  , sectop[secid][i].board);
            RPUSH("replies" , "%lu" , (unsigned long)sectop[secid][i].number);
            RPUSH("time"    , "%lu" , (unsigned long)sectop[secid][i].date);
            RPUSH("id"      , "%lu" , (unsigned long)sectop[secid][i].groupid);
        }
    }
    redisReply *reply;
    redisGetReply(redis, (void*)&reply);
    freeReplyObject(reply);
    redisFree(redis);

#undef RPUSH
#undef DEL
#endif
}