Skip to main content

cmd_flushdb.go

cmd_flushdb.go - Overview

This file defines the FLUSHDB command, which deletes all keys in the database. It includes the command's metadata, evaluation, and execution logic.

Detailed Documentation

cFLUSHDB

  • Purpose: Defines the metadata for the FLUSHDB command. This includes the name, syntax, help messages, example usage, evaluation function, and execution function.
  • Properties:
    • Name: "FLUSHDB" - The name of the command.
    • Syntax: "FLUSHDB" - The command's syntax.
    • HelpShort: "FLUSHDB deletes all keys." - A short description of the command.
    • HelpLong: A detailed description of the command's functionality.
    • Examples: Example usage of the FLUSHDB command.
    • Eval: evalFLUSHDB - The function to evaluate the command.
    • Execute: executeFLUSHDB - The function to execute the command.

init

  • Purpose: Registers the FLUSHDB command with the CommandRegistry.
  • Parameters: None
  • Returns: None

evalFLUSHDB

  • Purpose: Evaluates the FLUSHDB command, resetting the store if the correct number of arguments is provided.
  • Parameters:
    • c *Cmd: The command context.
    • s *store.Store: The data store instance.
  • Returns:
    • *CmdRes: cmdResOK if successful, cmdResNil otherwise.
    • error: An error if the wrong number of arguments is provided.

executeFLUSHDB

  • Purpose: Executes the FLUSHDB command across all shards in the shard manager.
  • Parameters:
    • c *Cmd: The command context.
    • sm *shardmanager.ShardManager: The shard manager instance.
  • Returns:
    • *CmdRes: cmdResOK if successful, nil otherwise.
    • error: An error if any of the shards return an error.

Getting Started Relevance: YES