Check the version of Redis
Asked Answered
I

3

7

I'd like to check the version of redis,
it could be accomplished on command line

In [181]: !redis-server --version
Redis server v=4.0.10 sha=00000000:0 malloc=libc bits=64 build=ea14acb2d1b3b56f

However, when it return the redis-py's version rather than redis version if

In [184]: redis.__version__
Out[184]: '2.10.6

It could be achieved in a wieldy way

In [186]: subprocess.run("redis-server --version", shell=True)
Redis server v=4.0.10 sha=00000000:0 malloc=libc bits=64 build=ea14acb2d1b3b56f
Out[186]: CompletedProcess(args='redis-server --version', returncode=0)

How could I check the version of redis directly with pure code?

Individuality answered 16/8, 2018 at 7:37 Comment(1)
Possible duplicate of how to check redis instance version?Slacks
G
10

Redis has the INFO command to get all sort of info about the server:

import redis

r = redis.StrictRedis(host='localhost', port=6379, db=0)
print(r.execute_command('INFO')['redis_version'])
Garamond answered 16/8, 2018 at 7:44 Comment(0)
O
1

From the cli you can use following command

redis-cli info

Sample Output

# Server
redis_version:4.0.1
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:f37081b32886670b
redis_mode:standalone
os:Darwin 16.7.0 x86_64
arch_bits:64
multiplexing_api:kqueue
atomicvar_api:atomic-builtin
gcc_version:4.2.1

or if you need version you can try with pipe cmd

redis-cli info | grep "redis_version"

Output

redis_version:4.0.1

i hope this will help

Ontologism answered 16/8, 2018 at 11:37 Comment(0)
N
0

Python Redis has the info function to get all info about redis server. We can get the redis_version from this function output.

red = redis.Redis(host='localhost', port=6379, db=0)
print(red.info().get('redis_version'))
Nika answered 24/1, 2023 at 5:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.