Giter Club home page Giter Club logo

memcached-nodejs's Introduction

Memcached Server - Work in progress

This repo contains a Memcached implementation with JavaScript. It listens for new connections on a given TCP port. You can find the part of the protocol implemented here. The full protocol can be found in the references at the end of this document.

Note: This only a little piece of the Memcached protocol.

About

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

You can find more about Memcached in the references at the end of this document.

Requirements

  • Nodejs version >= 12.16.1 LTS

Dependencies

  • ms: This package is used for handling with time using friendly time formats.
  • dotenv: This package is used to read environment variables.
  • Jest: This package is used for unit testing the software.
  • uuid: This package is used to generate random and unique strings for the casUnique key.

Installation

In order to start the server you will have to run the following commands in your console:


$ git clone https://github.com/SGarcia710/memcached-nodejs

$ cd memcached-nodejs

$ npm i

Now you will have to create a .env file at the root of the memcached server folder indicating the TCP port.


SERVER_PORT = 9000
SERVER_DOMAIN = localhost

As default, if the server doesn't receive the port through the .env file, it will use 8080.

After everything is seted up, you just have to run npm start at the root of the project and the server is going to listen requests at the given port.

Usage

These are two ways to use the server, throught command line or with the client. Here you will be examples to use both.

Command line

When you have started the server, it will listen any connection through the setted up TCP port. You can use it through the command line using the following command:


$ printf "set myKey 0 300 4 [noreply]\r\ndata\r\n" | nc localhost 8080

Client

There is a simple TCP client to send operations to the server. This is how you can use it:

const TCPClient = require('./utils/client')
const { PORT } = require('./src/assets/config');

const client  =  new  TCPClient(PORT, 'localhost');
client.sendOperation('set key 0 0 4 [noreply]\r\ndata\r\n');
client.sendOperation('add key2 0 0 4\r\ndata\r\n');

It will simply log the server response.

You can check the available commands and usage here.

Tests

Unit tests

The Memcached logical functions and the parser for the client's input have a set of Unit tests made with Jest. In order to run the tests you have to run npm test at the root of the project's folder.

Load tests

TODO

References

memcached-nodejs's People

Contributors

sgarcia710 avatar

Watchers

 avatar  avatar

memcached-nodejs's Issues

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.