API Reference

IceFireDB NoSQL API Reference #

Overview #

IceFireDB provides a Redis-compatible API with additional commands for decentralized operations. This document covers the supported commands, their syntax, and usage examples.

Command Categories #

Server Management Commands #

INFO #

Returns server information and statistics.

Syntax:

INFO [section]

Example:

INFO
INFO memory
INFO replication

Response: Returns a multi-bulk string with server information.

FLUSHALL #

Removes all keys from all databases.

Syntax:

FLUSHALL

Response: Returns the number of keys removed.

FLUSHDB #

Removes all keys from the current database.

Syntax:

FLUSHDB

Response: Returns the number of keys removed.

String Commands #

Supported String Operations #

CommandDescriptionStatus
SETSet key value✅ Implemented
GETGet key value✅ Implemented
APPENDAppend to string✅ Implemented
INCRIncrement integer✅ Implemented
DECRDecrement integer✅ Implemented
MGETGet multiple values✅ Implemented
MSETSet multiple values✅ Implemented
SETEXSet with expiration✅ Implemented

Hash Commands #

Supported Hash Operations #

CommandDescriptionStatus
HSETSet hash field✅ Implemented
HGETGet hash field✅ Implemented
HGETALLGet all fields✅ Implemented
HDELDelete field✅ Implemented
HINCRBYIncrement field✅ Implemented
HKEYSGet all keys✅ Implemented
HVALSGet all values✅ Implemented

List Commands #

Supported List Operations #

CommandDescriptionStatus
LPUSHPush to left✅ Implemented
RPUSHPush to right✅ Implemented
LPOPPop from left✅ Implemented
RPOPPop from right✅ Implemented
LLENGet list length✅ Implemented
LRANGEGet range✅ Implemented
LINDEXGet by index✅ Implemented

Set Commands #

Supported Set Operations #

CommandDescriptionStatus
SADDAdd to set✅ Implemented
SREMRemove from set✅ Implemented
SMEMBERSGet all members✅ Implemented
SISMEMBERCheck membership✅ Implemented
SCARDGet cardinality✅ Implemented
SINTERIntersection✅ Implemented
SUNIONUnion✅ Implemented

Sorted Set Commands #

Supported Sorted Set Operations #

CommandDescriptionStatus
ZADDAdd to sorted set✅ Implemented
ZREMRemove from sorted set✅ Implemented
ZRANGEGet range✅ Implemented
ZREVRANGEGet reverse range✅ Implemented
ZCARDGet cardinality✅ Implemented
ZSCOREGet score✅ Implemented
ZRANKGet rank✅ Implemented

Extended Commands for Decentralized Operations #

Storage Driver Management #

DRIVER.SELECT #

Select active storage driver.

Syntax:

DRIVER.SELECT driver_name

Supported Drivers:

  • leveldb - Local LevelDB storage
  • badger - Local BadgerDB storage
  • ipfs - IPFS decentralized storage
  • crdt - CRDT-based storage
  • ipfs-log - IPFS log storage
  • oss - Object storage service
  • hybriddb - Tiered storage

Example:

DRIVER.SELECT ipfs

DRIVER.INFO #

Get current driver information.

Syntax:

DRIVER.INFO

P2P Network Commands #

P2P.CONNECT #

Connect to P2P network node.

Syntax:

P2P.CONNECT peer_address

Example:

P2P.CONNECT /ip4/192.168.1.100/tcp/4001/p2p/QmPeerID

P2P.PEERS #

List connected P2P peers.

Syntax:

P2P.PEERS

CRDT Operations #

CRDT.SYNC #

Force CRDT synchronization.

Syntax:

CRDT.SYNC

CRDT.STATUS #

Get CRDT synchronization status.

Syntax:

CRDT.STATUS

Error Codes #

IceFireDB uses standard Redis error responses with additional error codes:

  • ERR wrong number of arguments - Incorrect command syntax
  • ERR unknown command - Unsupported command
  • ERR storage driver error - Storage backend failure
  • ERR p2p network error - P2P connectivity issues
  • ERR crdt sync conflict - CRDT synchronization conflict

Response Types #

IceFireDB supports all Redis response types:

  • Simple Strings: +OK\r\n
  • Errors: -ERR message\r\n
  • Integers: :1000\r\n
  • Bulk Strings: $5\r\nhello\r\n
  • Arrays: *2\r\n$5\r\nhello\r\n$5\r\nworld\r\n

Protocol Compatibility #

IceFireDB is fully compatible with Redis RESP (REdis Serialization Protocol). Clients can use any Redis client library to connect to IceFireDB.

Connection Example #

import redis

# Connect to IceFireDB
r = redis.Redis(host='localhost', port=11001, decode_responses=True)

# Standard Redis operations
r.set('key', 'value')
value = r.get('key')
print(value)  # Output: 'value'

# IceFireDB extended operations
r.execute_command('DRIVER.SELECT', 'ipfs')

Performance Considerations #

  • Use pipelining for bulk operations
  • Choose appropriate storage driver for your use case
  • Monitor P2P network latency for decentralized operations
  • Consider data consistency requirements when selecting CRDT vs RAFT mode

See Also #