API ReferenceKeys
Save
Save data to a key with optional expiration time
Syntax
Redix.Save(key, value, expires)Parameters
Prop
Type
Returns
Prop
Type
Examples
Basic Save
-- Save simple data
Redix.Save('player:123', {name = 'John', level = 50})Save with Expiration
-- Save with 1-hour expiration
Redix.Save('session:abc', {token = 'xyz'}, 3600)Complex Nested Data
-- Save complex nested data
Redix.Save('character:456', {
name = 'Jane Doe',
stats = {
health = 100,
armor = 50
},
inventory = {'item1', 'item2'}
})Use Cases
Player Profile
function SavePlayerProfile(playerId, profileData)
Redix.Save('player:' .. playerId .. ':profile', profileData)
endSession Management
function CreateSession(sessionId, userData)
-- Session expires in 2 hours
Redix.Save('session:' .. sessionId, userData, 7200)
endCache Query Results
function CacheQueryResult(query, result)
local cacheKey = 'cache:' .. query
-- Cache for 5 minutes
Redix.Save(cacheKey, result, 300)
endBest Practices
Always Set Expiration for Temporary Data
-- Good - temporary cache
Redix.Save('cache:query', result, 300)
-- Bad - permanent cache could fill memory
Redix.Save('cache:query', result)Use Consistent Key Naming
-- Good - organized naming
Redix.Save('player:123:profile', data)
Redix.Save('player:123:stats', stats)
-- Bad - inconsistent
Redix.Save('player_profile_123', data)
Redix.Save('stats_123', stats)