A memory database with key & value

Maintainers

Package info

github.com/ArefShojaei/Redis

pkg:composer/arefshojaei/redis

Transparency log

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-06-16 14:48 UTC

This package is auto-updated.

Last update: 2026-06-17 10:30:43 UTC


README

🚀 Redis - PHP In-Memory Key-Value Database

A lightweight Redis-inspired in-memory database built with PHP. Store, manage, and explore your data using a powerful CLI interface or a live web dashboard.

Redis

✨ Features

  • 🔑 Key-Value Storage - Fast in-memory data management
  • 💻 Interactive CLI - Manage your database through terminal commands
  • 🌐 Live Web Server - Explore your data from a browser interface
  • 📝 String Operations - Set, get, append, and manipulate text data
  • 🔢 Number Operations - Increment and decrement numeric values
  • 🗂️ Hash Support - Store structured objects using key-value pairs
  • 📚 List Support - Manage ordered collections of values
  • ⏱️ Expiration System - Set TTL for temporary data
  • Fast & Lightweight - Built entirely with pure PHP

📥 Installation

Requirements

  • PHP 8.1 or higher
  • Composer

Install with Composer

composer require arefshojaei/redis

Clone from GitHub

git clone https://github.com/ArefShojaei/Redis.git
cd Redis

🚀 Getting Started

Redis can be used in two different modes.

1. Interactive CLI Mode

Run the database shell:

php bin/redis-cli

Or make it executable:

chmod +x ./bin/redis-cli
./bin/redis-cli

2. Web Dashboard Mode

Start the live server:

php bin/redis-server

Or:

chmod +x ./bin/redis-server
./bin/redis-server

Then open your browser:

http://localhost:8000

📚 Data Types & Commands

🔤 String Commands

Set and get values:

set username Robert

get username

Set and return old value:

getSet username Kevin

Multiple values:

mset name=John age=25 country=USA

Append text:

append message World

Expiration:

setex token 3600 secret-key

ttl token

Delete:

del username
unlink user1 user2 user3

🔢 Number Commands

Increase and decrease numbers:

set counter 10

incr counter
decr counter

Custom increment:

incrBy counter 5

decrBy counter 2

🗂 Hash Commands

Create object-like data:

hset user name Robert

hset user age 25

Multiple fields:

hmset user name:Robert age:25 role:admin

Get data:

hget user name

hgetall user

Other operations:

hkeys user
hvals user
hlen user
hexists user age

📋 List Commands

Push values:

lpush tasks "Build Redis"

rpush tasks "Write Documentation"

Read data:

lrange tasks 0 10

llen tasks

Remove items:

lpop tasks

rpop tasks

🗄 Database Commands

Show all stored data:

dump

List all keys:

keys

Remove all data:

flushdb

🔚 Session Commands

Exit the CLI:

quit

Check connection:

ping

💡 Example Workflow

Create a simple user record:

hset user:1 name Robert

hset user:1 email robert@example.com

hset user:1 role admin

Retrieve the data:

hgetall user:1

🔥 Why This Project?

This project is useful for learning:

  • Database engine concepts
  • Key-value storage design
  • Command parsing
  • CLI application development
  • Memory management
  • Data structures implementation in PHP

It is a great educational project for understanding how systems like Redis work internally.

🤝 Contributing

Contributions are welcome.

  1. Fork the repository
  2. Create a feature branch
git checkout -b feature/amazing-feature
  1. Commit your changes:
git commit -m "Add amazing feature"
  1. Push your branch:
git push origin feature/amazing-feature
  1. Open a Pull Request

👨‍💻 Author

Aref Shojaei

⭐ Show Your Support

If this project helps you learn database internals or PHP system development, consider giving it a Star ⭐ on GitHub.

Your support motivates future improvements.