DBSIZE

Since 1.1.0Server

Syntax

DBSIZE
  • Flags: fast
  • ACL categories: @fast, @server
  • Arity: 1

Returns the number of keys in the current database, the one chosen with SELECT (database 0 unless changed). Keys in other databases are not counted.

It can include keys whose time to live has passed but that have not yet been deleted; INFO keyspace gives the count for every database at once.

Reply

The number of keys, as an integer.

Examples

> SET k1 v
OK
> SELECT 1
OK
> SET k2 v
OK
> DBSIZE
(integer) 1
> SELECT 0
OK
> DBSIZE
(integer) 1