Redix LogoDocumentation
API ReferenceKeys

Overview

Key-value operations are the foundation of Redix. These operations allow you to save, retrieve, and manage simple or complex data associated with keys with automatic JSON serialization.

Available Operations

Basic Operations

  • Save - Save data to a key with optional expiration
  • Get - Retrieve data from a key
  • GetMultiple - Retrieve multiple keys at once
  • SetMultiple - Set multiple key-value pairs at once

Key Management

Expiration Management

  • Expire - Set expiration time on a key
  • TTL - Get time-to-live of a key
  • Persist - Remove expiration from a key

Use Cases

Key-value operations are perfect for:

  • Player data storage with automatic JSON serialization
  • Session management with automatic expiration
  • Caching expensive database queries
  • Temporary data that needs TTL
  • Configuration storage

Quick Example

local Redix = exports.redix:GetInterface()

-- Save player data with 1-hour expiration
Redix.Save('player:123', {
    name = 'John',
    level = 50
}, 3600)

-- Retrieve player data
Redix.Get('player:123', function(err, data)
    print('Player:', data.name, 'Level:', data.level)
end)

-- Check if exists
Redix.Exists('player:123', function(err, exists)
    if exists then
        print('Player exists')
    end
end)