Vemcache is an in-memory vector database.

Overview

Vemcache

Vemcache is an in-memory vector database.

Vemcache can be thought of as the Redis equivalent for vector databases.

Getting Started

Prerequisites

  • Docker: To run Vemcache using Docker, you need to have Docker installed on your system. You can install Docker by following the instructions on the Docker website.
  • Rust: To build and run Vemcache, you need Rust and Cargo installed on your system. You can install them using rustup.

Building Vemcache

Using Docker

  1. Pull the Vemcache image from dockerhub
docker pull faizchishtie/vemcache
  1. Run the image
docker run --rm -it -p 7070:7070 faizchishtie/vemcache:latest

Using docker-compose

Add the following to your docker-compose.yml

version: "3.7"

services:
  vemcache:
    image: faizchishtie/vemcache:latest
    ports:
      - "7070:7070"
    environment:
      - VEMCACHE_HOST=0.0.0.0
      - VEMCACHE_PORT=7070
      - VEMCACHE_SECRET=mysecret

Locally

  1. Clone the Vemcache repository:
git clone https://github.com/faizchishtie/vemcache.git
cd vemcache
  1. Build Vemcache:
make build
  1. Run Vemcache
make run

Using Vemcache

Connect to Vemcache with a TCP client like telnet or nc.

Use telnet to connect to Vemcache

telnet 0.0.0.0 7070

Or use nc

nc 0.0.0.0 7070

Once connected, you can interact with the Vemcache server by sending commands.

Inserting Vectors

To insert a vector into the database, use the insert command followed by the vector values:

insert 0.5 0.7 0.2

To insert a vector with a specified key, use the named_insert command followed by the key and vector values:

named_insert my_vector 0.5 0.7 0.2

Retrieving Vectors

To retrieve a vector from the database using its key, use the get command followed by the key:

get my_vector

Removing Vectors

To remove a vector from the database using its key, use the remove command followed by the key:

remove my_vector

Performing Vector Operations

To calculate the cosine similarity between two vectors, use the vcosine command followed by the keys of the two vectors:

vcosine vector1 vector2

To find the k nearest neighbors of a vector, use the knn command followed by the key of the query vector and the value of k:

knn query_vector 3

To perform element-wise addition of two vectors, use the vadd command followed by the keys of the two vectors:

vadd vector1 vector2

To perform element-wise subtraction of two vectors, use the vsub command followed by the keys of the two vectors:

vsub vector1 vector2

To scale a vector by a scalar value, use the vscale command followed by the key of the vector and the scalar value:

vscale vector1 2.0

Dumping the Database

To dump the database to a JSON file, use the dump command followed by the path to the file:

dump vemcache.json

Closing the Connection

To exit the client, press Ctrl+C or type quit (if using telnet).

This concludes the basic usage of Vemcache for vector operations. For more advanced operations and detailed explanations of each command, refer to the Vemcache documentation.

Example Session

# User connects to Vemcache using telnet
$ telnet 0.0.0.0 7070
Trying 0.0.0.0...
Connected to 0.0.0.0.
Escape character is '^]'.

# User inserts a vector with the key "vector_a"
named_insert vector_a 0.5 0.7 0.2
OK

# User inserts another vector with the key "vector_b"
named_insert vector_b 0.1 0.9 0.4
OK

# User retrieves the vector with the key "vector_a"
get vector_a
[0.5, 0.7, 0.2]

# User calculates the cosine similarity between "vector_a" and "vector_b"
vcosine vector_a vector_b
Cosine Similarity: 0.8693

# User finds the nearest neighbor of "vector_a" (k=2)
knn vector_a 2
ID: vector_a, Vector: [0.5, 0.7, 0.2]
ID: vector_b, Vector: [0.1, 0.9, 0.4]

# User performs element-wise addition of "vector_a" and "vector_b"
vadd vector_a vector_b
[0.6, 1.6, 0.6]

# User scales "vector_a" by a factor of 2
vscale vector_a 2.0
[1.0, 1.4, 0.4]

# User removes "vector_a" from the database
remove vector_a
OK

# User attempts to retrieve "vector_a" again (expecting an error)
get vector_a
null

# Dump vemcache db
dump vemcache.json
Database dump successful: vemcache.json

# User exits the session
quit
Connection closed by foreign host.
You might also like...
rust database for you to use and help me make!

Welcome To Rust Database! What is this? this is a database for you to git clone and use in your project! Why should i use it? It is fast and it takes

Proof-of-concept for a memory-efficient data structure for zooming billion-event traces

Proof-of-concept for a gigabyte-scale trace viewer This repo includes: A memory-efficient representation for event traces An unusually simple and memo

This crate allows to generate a flat binary with the memory representation of an ELF.

flatelf Library This crate allows to generate a flat binary with the memory representation of an ELF. It also allows to generate a FLATELF with the fo

High concurrency, RealTime, In-memory storage inspired by erlang mnesia
High concurrency, RealTime, In-memory storage inspired by erlang mnesia

DarkBird is a Document oriented, high concurrency in-memory Storage, also persist data to disk to avoid loss any data The darkbird provides the follow

Support SIMD low-memory overhead and high-performance adaptive radix tree.

Artful Artful is an adaptive radix tree library for Rust. At a high-level, it's like a BTreeMap. It is based on the implementation of paper, see The A

A additional Rust compiler pass to detect memory safe bugs of Rust programs.

SafeDrop A additional Rust compiler pass to detect memory safe bugs of Rust programs. SafeDrop performs path-sensitive and field-sensitive inter-proce

🧪 The versatile and intuitive memory hacking framework.

🧪 hax 🤔 About hax is a Rust crate designed to make memory hacking, game hacking, cheat development, and any other low level memory based development

Library and proc macro to analyze memory usage of data structures in rust.
Library and proc macro to analyze memory usage of data structures in rust.

Allocative: memory profiler for Rust This crate implements a lightweight memory profiler which allows object traversal and memory size introspection.

Owner
Faizaan Chishtie
swe
Faizaan Chishtie
An AI-native lightweight, reliable, and high performance open-source vector database.

What is OasysDB? OasysDB is a vector database that can be used to store and query high-dimensional vectors. Our goal is to make OasysDB fast and easy

Oasys 3 Dec 25, 2023
A small in-memory key value database for rust

SmollDB Small in-memory key value database for rust This is a small in-memory key-value database, which can be easly backed up in a file or stream and

null 13 Dec 15, 2022
Powerful math lib for Vector, Matrix and Quaternion operations

An opinionated, powerful math lib for Vector2, Vector3, Matrix and Quaternion operations Vector2 Add, Sub, Div, Mul, Eq Distance Move towards target a

O(ʒ) 4 Mar 28, 2022
Powerful math lib for Vector, Matrix and Quaternion operations

An opinionated, powerful math lib for Vector2, Vector3, Matrix and Quaternion operations Vector2 Add, Sub, Div, Mul, Eq Distance Move towards target a

O(ʒ) 4 Mar 28, 2022
A HashMap/Vector hybrid: efficient, ordered key-value data storage in Rust.

hashvec A HashVec is a hash map / dictionary whose key-value pairs are stored (and can be iterated over) in a fixed order, by default the order in whi

Skye Terran 2 May 16, 2022
Type erased vector. All elements have the same type.

Type erased vector. All elements have the same type. Designed to be type-erased as far as possible - most of the operations does not know about concre

null 7 Dec 3, 2022
Compact, clone-on-write vector and string.

ecow Compact, clone-on-write vector and string. Types An EcoVec is a reference-counted clone-on-write vector. It takes up two words of space (= 2 usiz

Typst 78 Apr 18, 2023
The Fast Vector Similarity Library is designed to provide efficient computation of various similarity measures between vectors.

Fast Vector Similarity Library Introduction The Fast Vector Similarity Library is designed to provide efficient computation of various similarity meas

Jeff Emanuel 243 Sep 6, 2023
The first compute-centric vector graphic video game

??️ Vong This repository contains source code for the first native use of a compute-centric vector graphics video game, inspired by Pong. ✍️ Authors @

Spencer C. Imbleau 29 Nov 24, 2023
Build database expression type checker and vectorized runtime executor in type-safe Rust

Typed Type Exercise in Rust Build database expression type checker and vectorized runtime executor in type-safe Rust. This project is highly inspired

Andy Lok 89 Dec 27, 2022