Skip to content

nktauserum/ht

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ht

EN / RU

Literally a hash table & rw-mutex over HTTP. This is an educational project, created to better understand low-level processes below abstraction levels. So, not perfect. It uses only the necessary dependencies: stdlib, posix threads and linux-specific libraries.

Hashing is performed by the djb2 algorithm, collisions are handled with linear probing in the not beautiful way. Server is built according to the scheme producer-consumer: the main thread receives incoming requests from epoll in a non-blocking way and puts them into a ring buffer.

These requests are distributed between worker threads of a configurable count. Requests are parsed by them and interact with hash-table. A separate thread is responsible for tracking the expiration of records. There is a read-write mutex, of course.

All buffers are preallocated, there's no dynamic resizing - only compile-time configuration.

Building and running

This project has been tested only on Linux.

  1. Clone this repository.
  2. make run

Interacting

The server listens on port 5000 by default. You can use simple curl requests to interact with it.

Read: curl -X "GET" http://localhost:5000/field

Write: curl -X "POST" -d "YOUR DATA" http://localhost:5000/field

If you want, you can add a TTL to your data by setting the TTL HTTP header:

-H "TTL: %your_time_in_seconds%"

To-do

  • More concize logs
  • Some persistence
  • Basic authorization
  • SSL

About

Key-value storage over HTTP written in C.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors