Back to Pikiwidb

Pika Currently Supported Redis Interfaces

docs/ops/API_en.md

4.0.37.1 KB
Original Source

Pika Currently Supported Redis Interfaces

Pika supports the interfaces for Redis's five types (string, hash, list, set, zset). Below is a compatibility summary for the five Redis data structures.

Legend for the table:

IconMeaning
oFully supported; usage is identical to Redis
!Functionally supported, but usage or output has some differences from Redis; please note
×Not yet supported

Keys

InterfaceDELDUMPEXISTSEXPIREEXPIREATKEYSMIGRATEMOVEOBJECT
Statusoxooooxxx
InterfacePERSISTPEXPIREPEXPIREATPTTLRANDOMKEYRENAMERENAMENXRESTORESORT
Statuso!!oxxxxx
InterfaceTOUCHTTLTYPEUNLINKWAITSCAN
Statusxo!ox!

Notes:

  • PEXPIRE: Cannot be precise to milliseconds; the underlying layer automatically truncates to second-level precision.
  • PEXPIREAT: Cannot be precise to milliseconds; the underlying layer automatically truncates to second-level precision.
  • SCAN: Iterates through a snapshot of the current DB sequentially. Since Pika allows duplicate names five times, scan has a priority output order: string -> hash -> list -> zset -> set.
  • TYPE: Since Pika allows duplicate names five times, type has a priority output order: string -> hash -> list -> zset -> set. If this key exists in string, only "string" is output; if not, hash is output, and so on.
  • KEYS: The KEYS command supports scanning specific data types via a parameter, e.g., keys * [string, hash, list, zset, set].

Strings

InterfaceAPPENDBITCOUNTBITFIELDBITOPBITPOSDECRDECRBYGETGETBIT
Statusoox!oooo!
InterfaceGETRANGEGETSETINCRINCRBYINCRBYFLOATMGETMSETMSETNXSTRLEN
Statusooooooooo
InterfacePSETEXSETSETBITSETEXSETNXSETRANGE
Statusoo!ooo

Notes:

  • BIT operations: Unlike Redis, Pika's bit operation range is 2^21, with a maximum bitmap size of 256 KB. Redis setbit only updates the key's value. But Pika uses RocksDB as the storage engine, which only writes new data and only deletes old data from disk during compaction. If Pika's bit operation range matched Redis's 2^32, each setbit on the same key might store a 512 MB value in RocksDB. This creates a serious performance risk, so Pika's bit operation range has been reduced.

Hashes

InterfaceHDELHEXISTSHGETHGETALLHINCRBYHINCRBYFLOATHKEYSHLENHMGETHMSET
Statusoooooooooo
InterfaceHSETHSETNXHVALSHSCANHSTRLEN
Status!oooo

Notes:

  • HSET operation: Setting multiple field-value pairs with a single command is temporarily not supported. Please use HMSET instead.

Lists

InterfaceLINDEXLINSERTLLENLPOPLPUSHLPUSHXLRANGELREMLSETLTRIM
Statusoooooxoooo
InterfaceRPOPRPOPLPUSHRPUSHRPUSHXBLPOPBRPOPBRPOPLPUSH
Statusoooooox

Sets

InterfaceSADDSCARDSDIFFSDIFFSTORESINTERSINTERSTORESISMEMBERSMEMBERSSMOVESPOP
Statusoooooooooo
InterfaceSRANDMEMBERSREMSUNIONSUNIONSTORESSCAN
Status!oooo

Notes:

  • SRANDMEMBER: Time complexity O(n), relatively slow.

Sorted Sets

InterfaceZADDZCARDZCOUNTZINCRBYZRANGEZRANGEBYSCOREZRANKZREMZREMRANGEBYRANKZREMRANGEBYSCORE
Statusoooooooooo
InterfaceZREVRANGEZREVRANGEBYSCOREZREVRANKZSCOREZUNIONSTOREZINTERSTOREZSCANZRANGEBYLEXZLEXCOUNTZREMRANGEBYLEX
Statusoooooooooo
InterfaceZPOPMAXZPOPMINZREVERANGEBYLEX
Statusooo
  • ZADD options [NX|XX] [CH] [INCR] are temporarily not supported.

HyperLogLog

InterfacePFADDPFCOUNTPFMERGE
Statusooo

Notes:

  • Error within 1% for under 500k, less than 3% for under 1 million, but at the cost of additional time.

GEO

InterfaceGEOADDGEODISTGEOHASHGEOPOSGEORADIUSGEORADIUSBYMEMBER
Statusoooooo

BitMap

InterfaceSETBITGETBITBITPOSBITOPBITCOUNT
Statusooooo

Pub/Sub

InterfacePSUBSCRIBEPUBSUBPUBLISHPUNSUBSCRIBESUBSCRIBEUNSUBSCRIBE
Statusoooooo

Notes:

  • Keyspace notifications are temporarily not supported.

Admin Commands (only those compatible with Pika are listed)

InterfaceINFOCONFIGCLIENTPINGBGSAVESHUTDOWNSELECTTYPEHELLO
Status!o!ooo!!o

Notes:

  • info: Supports full output and pattern-matched output. For example, info stats shows statistics. Note that key space differs from Redis — Pika displays key space by type rather than by DB (since Pika has no concept of databases). Pika's key space statistics are passive and must be manually triggered. Pika's key space statistics are accurate. To trigger: execute keyspace command, then Pika will count in the background. You can use keyspace readonly to view without re-triggering. If current data is 0, it's still being counted. info commandstats can query call count and time statistics (average time) for each command. Unlike Redis, the time unit we use is milliseconds.

  • client: The current client command supports client list, client kill, and client setname. client list shows less information than Redis.

  • select: This command had no effect before version 3.1.0; since 3.1.0 it is consistent with Redis.

  • ping: This command only supports use without parameters, i.e., PING, and the client returns PONG.


Pika Pub/Sub Documentation

Available version: >= 2.3.0

Note: Keyspace notification functionality is not currently supported.

Pika Publish/Subscribe Commands

The following Pub/Sub commands are fully compatible with Redis:

  • PUBSUB subcommand [argument [argument ...]]
  • PUBLISH channel message
  • SUBSCRIBE channel [channel ...]
  • PSUBSCRIBE pattern [pattern ...]
  • UNSUBSCRIBE [channel [channel ...]]
  • PUNSUBSCRIBE [pattern [pattern ...]]

For usage details, refer to Redis's Pub/Sub documentation.

Important Notes

  • Key duplication: Since each Pika type operates independently, duplicate keys are allowed. For example, key abc can exist in both string and hash at the same time. A key can be duplicated at most 5 times (for the 5 major types), but cannot be duplicated within the same interface. Therefore, it is recommended to avoid using exactly the same key across different types.

  • Multi-DB: Pika supports multiple databases since version 3.1.0. For changes to related commands and parameters, refer to the Pika 3.1.0 multi-DB version command/parameter change reference document.

  • Data display: Pika displays key space by type rather than by DB (since Pika has no concept of databases). Key statistics in Pika are passive and must be manually triggered; they do not output immediately. The command is: info keyspace [0|1], defaulting to 0 (no trigger). Pika's keyspace statistics are accurate.