arefshojaei / redis
Memory database with key & value
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/arefshojaei/redis
Requires
- php: ^8.0
Requires (Dev)
- phpunit/phpunit: ^10
This package is auto-updated.
Last update: 2026-02-23 18:45:40 UTC
README
Redis library
Memory database with key & value
Installation
Using Composer
composer require arefshojaei/redis
Using Github
git clone https://github.com/ArefShojaei/Redis.git
How to use that?
1- Run in Terminal (CLI)
php bin/redis-cli
2- Run as Live-server to explore data in page
php bin/redis-server
Commands:
String
Set value by key
set [key] [value]
Get value by key
get [key]
Set & Get value by key
getSet [key] [value]
Get string length
strlen [key]
Set multiple values
mset [key=value] [key=value] [key=value] [...]
Get multiple values
mset [key-1] [key-2] [key-3] [key-n]
Append value to string
set message Hello append message World # HelloWorld
Get range of string from start to end by index
set message Hello getRange message 0 1 # He
Delete value by key
del [key]
Delete multiple values by keys
unlink [key-1] [key-2] [key-3] [key-n]
Set expire-time for string
setex [key] [seconds] [value]
Get current expire-time seconds to delete the value
setex [key]
Check to exist value by key
exists [key]
Number
Increment number by key
set counter 5 # Init state incr counter # Update the state => 5+1 = 6
Decrement number by key
set counter 5 # Init state decr counter # Update the state => 5-1 = 4
Increment number with value
set counter 5 # Init state incrBy counter 10 # Update the state => 5+10 = 15
Decrement number with value
set counter 5 # Init state decrBy counter 5 # Update the state => 5-5 = 0
Hash
Set new hash
hset [name] [key] [value]
Set multiple hash data by key & value
hmset [name] [key:value] [key:value] [...]
Get hash value by key
hget [name] [key]
Get all hash data
hgetall [name]
Get hash length
hlen [name]
Get all hash keys
hkeys [name]
Get all hash values
hvals [name]
Get multiple hash values by keys
hvals [name] [key-1] [key-2] [key-3] [key-n]
Delete hash value by key
hdel [name] [key]
Check to exist hash value by key
hexists [name] [key]
List
Push values to list
lpush [name] [value]
Pop value from the list by name
lpop [name]
Get length of list by name
llen [name]
Get value of list by index
llen [name] [index]
Get range of list from start to end by name
llen [name] [start] [end]
Remove value of list by index
lrem [name] [index]
Set key & value to list by name
lset [name] [key] [value]
Remove value of list at end of list
Rpop [name]
Add new value of list at end of list
Rpush [name] [value]
Store
Get store
dump
Get all store keys
keys
Destroy the store
flushdb
Session
Terminate current session
quit
General
FUN!
ping
