Giter VIP home page Giter VIP logo

memwared's Introduction

memwared

memwared is a simple middle ware, support mongodb.

memwared是一个轻量级的数据库连接池,目前仅仅支持mongodb。

library

  • libevent-1.4.13-stable
  • mongo-c-driver-1.1.0
  • msgpack-c-cpp-0.6.0

description

memwared 是一个单进程的系统,也就表明你可以再一台机器上开启多个实例,各个实例指定不同的端口。 内部工作采用多线程方式,主程序执行流放在主线程中,主线程中主要负责初始化,循环分发,创建子线程,建立和分发连接等。 子线程用于处理到来的连接的读写,及相应的触发事件。 使用libevent网络库处理io事件,利用msgpack协议作为通讯协议,mongo-c-driver应为其中已经封装了client_pool。

Example

php client

more code

<?php
	...
	$socket = System_Socket::create(AF_INET, SOCK_STREAM, SOL_TCP);
    $socket->connect('127.0.0.1',8021);
    $in = array(
        'gamedb',
        'entity_hs_card_zhcn',
        'find',
        array(array("cost"=>20))
    );
    $in = msgpack_pack($in);
    $socket->write($in, strlen($in));

    $out = '';
    $res = '';
    while (true){
        $out = $socket->read(1024, PHP_NORMAL_READ);
        if ($out === false){
            break;
        }
        $res .= $out;

    }

    DebugTools::print_r($res);
    ...
?>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.