All Projects → egladysh → memcacher

egladysh / memcacher

Licence: MIT license
C++ implementation of Memcache Binary Protocol.

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to memcacher

memcache
Node.js memcached client with the most efficient ASCII protocol parser
Stars: ✭ 26 (+62.5%)
Mutual labels:  memcached, protocol
metacom
RPC communication protocol for Metarhia stack 🔌
Stars: ✭ 42 (+162.5%)
Mutual labels:  protocol
mqtt rs
MQTT broker in Rust
Stars: ✭ 23 (+43.75%)
Mutual labels:  protocol
homebrew-extensions
🍻 Homebrew tap for PHP extensions
Stars: ✭ 264 (+1550%)
Mutual labels:  memcached
minecraft-protocol
Library for decoding and encoding Minecraft packets
Stars: ✭ 20 (+25%)
Mutual labels:  protocol
PSAVanCanBridge
VAN - CAN protocol bridge (V2C) for cars made by PSA Group (Peugeot, Citroen)
Stars: ✭ 67 (+318.75%)
Mutual labels:  protocol
diepindepth
Collection of protocol, memory, and other information for the browser game diepio
Stars: ✭ 39 (+143.75%)
Mutual labels:  protocol
MqttAndroidExample
An example Android app using MQTT protocol
Stars: ✭ 19 (+18.75%)
Mutual labels:  protocol
ipfs-companion
Browser extension that simplifies access to IPFS resources on the web
Stars: ✭ 1,745 (+10806.25%)
Mutual labels:  protocol
LXFProtocolTool
由Swift中协议方式实现功能的实用工具库【Refreshable、EmptyDataSetable 支持 Rx 】
Stars: ✭ 101 (+531.25%)
Mutual labels:  protocol
protocol-registry
This module allows you to set custom protocol handler for your nodejs app.
Stars: ✭ 45 (+181.25%)
Mutual labels:  protocol
diepssect
A public repo for hacky diep stuff - networking protocol, WebAssembly, memory editing, & physics
Stars: ✭ 26 (+62.5%)
Mutual labels:  protocol
ErpNet.FP
ErpNet.FP is a light-weight cross-platform Http server facilitating printing to fiscal printers through simple JSON Api.
Stars: ✭ 75 (+368.75%)
Mutual labels:  protocol
limits
Rate limiting using various strategies and storage backends such as redis & memcached
Stars: ✭ 178 (+1012.5%)
Mutual labels:  memcached
WSD-python
Web Services for Devices (WSD) tools and utilities for cross platform support
Stars: ✭ 22 (+37.5%)
Mutual labels:  protocol
FTAPIKit
Declarative and generic REST API framework using Codable.
Stars: ✭ 18 (+12.5%)
Mutual labels:  protocol
go-elasticache
Thin abstraction over the Memcache client package gomemcache (https://github.com/bradfitz/gomemcache) allowing it to support AWS ElastiCache cluster nodes
Stars: ✭ 15 (-6.25%)
Mutual labels:  memcached
Rubicon
Swift parser + mock generator
Stars: ✭ 42 (+162.5%)
Mutual labels:  protocol
rconsharp
rconsharp is a Valve RCON protocol implementation written in C# targeting netstandard 2.1
Stars: ✭ 43 (+168.75%)
Mutual labels:  protocol
wayland-explorer
Easily browse and read Wayland protocols documentation
Stars: ✭ 78 (+387.5%)
Mutual labels:  protocol

memcacher

memcacher is a minimalistic C++ implementation of Memcache Binary Protocol. Set/Delete (with CAS) and Get commands are currently supported. This project has a somewhat interesting history. It started as a coding exercise. The implementation uses the C++11 move semantic heavily that minimizes the number of required data copying while keeping the code clean. The RAII idiom helps with a clean code as well as making it exception "safer". The cache uses LRU to reclaim memory when needed. The performance is comparable with the standard memcached that is implemented in C, and has customized memory allocators.

Build

Requirements

C++11 and a system that support kqueue (OSX, FreeBSD) or epoll (Linux). Actually we abstract kqueue as epoll api's (see kqepoll.cpp for details).

Steps

  • Suppose you have the source in [HOME]/work/memcacher

  • Create a build folder in [HOME]/work, and go there.

    $mkdir build

    $cd build

  • Run cmake.

    $cmake ../memcacher

  • Build it.

    $make

  • Your binary will bin in [HOME]/work/build

Testing

  • I used https://github.com/jaysonsantos/python-binary-memcached

  • pytest, mock, pytest-cov and flake8 are required

    sudo pip install pytest

    sudo pip install pytest-cov

    sudo pip install mock

    sudo pip install flake8

  • You can find a simple test script under [HOME]/work/memcacher/test.

    cd [HOME]/work/memcacher/test

    sudo pytest -v test_set_get.py

  • If you built in another location, please make sure to point to you binary in conftest.py.

Project notes

  • I used the following open source codes.

    • protocol_binary.h from memcached that contains definitions for the binary protocol data types.
    • murmur3 hash, binary hasher.
  • Command line options.

    memcacher [options]

      -l IP address of the listening socket, default 127.0.0.1
      -d run as daemon
      -p Port number, default is 11211
      -t Number of threads, default is 1 (just the main thread)
      -c Max number of simultaneous connections, default is 1024
      -m Max cache memory (MB), default is 500
    
  • Example: memcacher -p 5000 -t 2 -m 100

  • The following obvious parameters can be configured in config.h

    static const size_t MAX_KEYLEN = 250; //bytes

    static const size_t MAX_VALUELEN = 1024*1024; //1Mb

    static const size_t MAX_WRITE_SIZE = 4*1204; //max size of one write on connections

Performance notes

  • By default all processing happens on the main thread, it could be a good idea to set it to the number of cores (option -t). For example if there are 4 cores, set the option to -t4. In any case, if there is a need to handle a lot of concurrent connections, this is the option to look at. All parallel connections are distributed among available thread in round-robin.

TODO

  • Remaining of the protocol
  • SASL authentication
  • Custom memory allocators
  • Support for socket files
  • Thread-safe logging
  • Test various hasher's
  • Stats/profiling
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].