moledb
v0.1.6
Published
Fast, lightweight in-memory database. Redis-compatible protocol with persistence, replication, and Sentinel support.
Maintainers
Readme
Mole DB
Fast, lightweight in-memory database with Redis-compatible protocol.
Features
- Redis-compatible protocol - Use existing Redis clients
- Persistence - AOF (Append-Only File) support
- Replication - Master-replica setup
- Sentinel - High availability monitoring
- TTL support - Automatic key expiration
- Memory management - LRU eviction policies
- Fast - Built in Go for performance
Installation
npm install -g moledbQuick Start
Start the server
moleServer starts on 127.0.0.1:7379 by default.
Connect with CLI
mole-cli
127.0.0.1:7379> SET mykey "Hello"
OK
127.0.0.1:7379> GET mykey
"Hello"Server Options
mole [options]
Options:
-addr string
TCP address to listen on (default "127.0.0.1:7379")
-aof
Enable AOF persistence
-aof-path string
AOF file path (default "./mole.aof")
-aof-fsync string
AOF fsync policy: always|everysec|no (default "everysec")
-maxmemory int
Max memory in bytes (0 = no limit)
-maxmemory-policy string
Eviction policy: noeviction|allkeys-lru (default "noeviction")
-role string
Server role: master|replica (default "master")
-master-addr string
Master address (required for replica)Examples
Start with persistence:
mole -aof -aof-path ./data/mole.aofStart replica:
mole -role replica -master-addr 127.0.0.1:7379 -addr 127.0.0.1:7380CLI Usage
Interactive mode:
mole-cliSingle command:
mole-cli SET key value
mole-cli GET keyConnect to different host:
mole-cli -h 192.168.1.100 -p 7379Supported Commands
GET,SET,DEL,EXISTSEXPIRE,TTLINCR,DECRLPUSH,RPUSH,LPOP,RPOP,LRANGESADD,SMEMBERS,SISMEMBERHSET,HGET,HGETALLKEYS,PING,INFO- And more...
Use with Node.js
const redis = require('redis');
const client = redis.createClient({ port: 7379 });
await client.connect();
await client.set('key', 'value');
const value = await client.get('key');
console.log(value); // 'value'License
MIT
