animus

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

README

animus

Build and Test GoDoc License

Animus is an in-memory database (like Redis) written in Go. It offers a lightweight, high-performance storage solution with support for various commands and data structures.

Working Commands

GETEX - GETEX [KEY] [EXPIRATION]

Gets the value of a key and sets an expiration.

GETRANGE - GETRANGE [KEY] [START] [END]

Gets a substring of the string stored at a key.

INCR - INCR [KEY]

Increments the integer value of a key by one.

LCS - LCS [KEY1] [KEY2] LEN

Finds the Longest Common Subsequence between the value of two keys.

MGET key [keys ...]

Returns the values for all the keys, nil for a non-existing key.

MSET key value [keys values ...]

Sets the values for all the key - value pairs.

INCRBYFLOAT - INCRBYFLOAT [KEY] [INCREMENT]

Increments the float value of a key by the given amount.

RPOP - RPOP [KEY] [COUNT]

Removes and returns the last element(s) of the list stored at key.

DECRBY - DECRBY [KEY] [DECREMENT]

Decrements the integer value of a key by the given amount.

GETDEL - GETDEL [KEY]

Gets the value of a key and deletes it.

SET - SET [KEY] [VALUE] [EX SECONDS|PX MILLISECONDS|KEEPTTL]

Sets the value of a key with optional expiration.

GETSET - GETSET [KEY] [VALUE]

Gets the previous key value and then sets it to the passed value.

INCRBY - INCRBY [KEY] [INCREMENT]

Increments the integer value of a key by the given amount.

HSET - HSET [KEY] [FIELD] [VALUE]

Sets a field in the hash stored at key to a value.

HGET - HGET [KEY] [FIELD]

Gets the value of a field in the hash stored at key.

PING - PING [ARGUMENT]

Returns PONG to test server responsiveness.

APPEND - APPEND [KEY] [VALUE]

Appends a value to a key and returns the new length of the string.

DECR - DECR [KEY]

Decrements the integer value of a key by one.

GET - GET [KEY]

Gets the value of a key.

RPUSH - RPUSH [KEY] [VALUE] [VALUE ...]

Inserts one or more elements at the end of the list stored at key.

HELP - HELP [COMMAND]

Shows documentation for available commands.

Features

  • Expiration Mechanism: Support for TTL (Time-to-Live) and LRU (Least Recently Used) expiry policies.
  • Data Types: Support for strings, lists, hashes, and advanced data structures.
  • Key Management: Automatic key expiration, deletion, and manipulation.
  • Concurrency: Optimized for high concurrency and scalability.

Roadmap

The following features are planned for future releases:

  • Configuration Support: Allow users to configure expirations, max memory, etc.
  • Key Locking: Implement pools for key locks to handle high memory usage and key-based locking for essentials.
  • Advanced Data Structures: Expand support for additional data structures like sets, sorted sets, and more.
  • Replication: Master-slave replication to enable high availability and fault tolerance.
  • Pub/Sub: Real-time messaging with Publish/Subscribe functionality.
  • Performance Optimizations: Optimizations to the event loop for enhanced performance.
  • Clustering & Sharding: Scalable architecture with clustering and sharding.

Test Coverage

  • Test coverage can be verified by generating a cover.html file.

  • To generate the cover.html file, run these commands:

go test -v -coverprofile cover.out ./...
go tool cover -html cover.out -o cover.html

Release Notes

v0.0.1
v0.0.2
v0.0.3
  • Add these functions

    • GETSET, INCR, INCRBY, INCRBYFLOAT
  • Added key based locking instead of locking the store globally, leading to huge increase in concurrency.

License

Animus is licensed under the GNU General Public License v3.0 (GPL-3.0). See the LICENSE file for more information.

Documentation

Overview

Package animus provides an in-memory database (similar to Redis) implemented in Go.

Animus supports various data types like strings, hashes, and lists, along with features such as expiration handling (TTL, LRU), and basic commands.

Key Features:

  • **PING (String)**: PING [ARGUMENT] Returns PONG to test server responsiveness.
  • **APPEND (String)**: APPEND [KEY] [VALUE] Appends a value to a key and returns the new length of the string.
  • **DECR (String)**: DECR [KEY] Decrements the integer value of a key by one.
  • **DECRBY (String)**: DECRBY [KEY] [DECREMENT] Decrements the integer value of a key by the given amount.
  • **GET (String)**: GET [KEY] Gets the value of a key.
  • **GETDEL (String)**: GETDEL [KEY] Gets the value of a key and deletes it.
  • **GETEX (String)**: GETEX [KEY] [EXPIRATION] Gets the value of a key and sets an expiration.
  • **GETRANGE (String)**: GETRANGE [KEY] [START] [END] Gets a substring of the string stored at a key.
  • **GETSET (String)**: GETSET [KEY] [VALUE] Gets the previous key value and then sets it to the passed value.
  • **INCR (String)**: INCR [KEY] Increments the integer value of a key by one.
  • **INCRBY (String)**: INCRBY [KEY] [INCREMENT] Increments the integer value of a key by the given amount.
  • **INCRBYFLOAT (String)**: INCRBYFLOAT [KEY] [INCREMENT] Increments the float value of a key by the given amount.
  • **LCS (List)**: LCS [KEY1] [KEY2] LEN Finds the Longest Common Subsequence between the value of two keys. Send the optional LEN argument to get just the length
  • **MGET (String)**: MGET key [key ...] Returns the values for all the keys. Returns nil for a non-existing key.
  • **MSET (String)**: MSET key value [key1 value1 ...] Sets the values for all the keys value pair.
  • **SET (String)**: SET [KEY] [VALUE] [EX SECONDS|PX MILLISECONDS|KEEPTTL] Sets the value of a key with optional expiration.
  • **HSET (Hash)**: HSET [KEY] [FIELD] [VALUE] Sets a field in the hash stored at key to a value.
  • **HGET (Hash)**: HGET [KEY] [FIELD] Gets the value of a field in the hash stored at key.
  • **RPOP (List)**: RPOP [KEY] [COUNT] Removes and returns the last element(s) of the list stored at key.
  • **RPUSH (List)**: RPUSH [KEY] [VALUE] [VALUE ...] Inserts one or more elements at the end of the list stored at key.
  • **HELP (Help)**: HELP [COMMAND] Shows documentation for available commands.

Roadmap:

  • Advanced data structures (Sets, Sorted Sets)
  • Master-Slave replication
  • Pub/Sub for messaging
  • Performance optimizations
  • Clustering and sharding

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL