Skip to content

Commit

Permalink
LUA edits
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Dec 12, 2024
1 parent 45569fd commit f29ade3
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 6 deletions.
8 changes: 8 additions & 0 deletions lua/DSMGetTable.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!lua flags=no-writes

-- The SMA-X library for Redis
-- Author: Attila Kovacs
-- Version: 11 December 2024
--
-- GitHub: Smithsonian/smax-server

-- keys: [0]
-- arguments: host target key
-- returns name SMA-X table name under which the data can be found
Expand Down
8 changes: 8 additions & 0 deletions lua/DelKey.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!lua

-- The SMA-X library for Redis
-- Author: Attila Kovacs
-- Version: 11 December 2024
--
-- GitHub: Smithsonian/smax-server

-- keys: [1+] SMA-X keywords
-- arguments: (none)
-- returns: (integer) the total number of fields deleted, including in sub-structures, and in parent structures.
Expand Down
8 changes: 8 additions & 0 deletions lua/GetStruct.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!lua flags=no-writes

-- The SMA-X library for Redis
-- Author: Attila Kovacs
-- Version: 11 December 2024
--
-- GitHub: Smithsonian/smax-server

-- keys: [1] Structure name (hash table)
-- arguments: (none)
-- Arrays of:
Expand Down
8 changes: 8 additions & 0 deletions lua/HGetWithMeta.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!lua flags=no-writes

-- The SMA-X library for Redis
-- Author: Attila Kovacs
-- Version: 11 December 2024
--
-- GitHub: Smithsonian/smax-server

-- keys: [1] Hash table to get value from
-- arguments: field
-- returns an array of { value, type, dim, timestamp, origin, serial }
Expand Down
8 changes: 8 additions & 0 deletions lua/HMGetWithMeta.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!lua flags=no-writes

-- The SMA-X library for Redis
-- Author: Attila Kovacs
-- Version: 11 December 2024
--
-- GitHub: Smithsonian/smax-server

-- keys: [1] Hash table to get values from
-- arguments: field1 field2 ...
-- returns an array of arrays { {values}, {types}, {dims}, {timestamps}, {origins}, {serials} }
Expand Down
8 changes: 8 additions & 0 deletions lua/HMSetWithMeta.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!lua

-- The SMA-X library for Redis
-- Author: Attila Kovacs
-- Version: 11 December 2024
--
-- GitHub: Smithsonian/smax-server

-- Needed for server-side time-stamping.
redis.replicate_commands()

Expand Down
8 changes: 8 additions & 0 deletions lua/HSetWithMeta.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!lua

-- The SMA-X library for Redis
-- Author: Attila Kovacs
-- Version: 11 December 2024
--
-- GitHub: Smithsonian/smax-server

-- Needed for server-side timestamping...
redis.replicate_commands()

Expand Down
21 changes: 15 additions & 6 deletions lua/smax.lib
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!lua name=smax

-- The SMA-X library for Redis
-- Author: Attila Kovacs
-- Version: 11 December 2024
--
-- GitHub: Smithsonian/smax-server




local function smax_set(KEYS, ARGS)
-- keys: [1] Hash table to add value to
-- arguments: 1:origin 2:field 3:value 4:type 5:dim
Expand Down Expand Up @@ -328,40 +337,40 @@ end
redis.register_function{
function_name='smax_set',
callback=smax_set,
description='(table | origin, key, value, type, dim) Sets an SMA-X leaf node'
description='Sets an SMA-X leaf node (table | origin, key, value, type, dim) '
}

redis.register_function{
function_name='smax_get',
callback=smax_get,
flags={ 'no-writes' },
description='(table | key) Returns an SMA-X variable (table:key) with metadata'
description='Returns an SMA-X variable (table:key) with metadata (table | key)'
}

redis.register_function{
function_name='smax_mset',
callback=smax_mset,
flags={},
description='(table | origin { key1, value1, type1, dim1 } ...) Sets multiple SMA-X entrie in the same table'
description='Sets multiple SMA-X entrie in the same table (table | origin { key1, value1, type1, dim1 } ...)'
}

redis.register_function{
function_name='smax_mget',
callback=smax_mget,
flags={ 'no-writes' },
description='(table | key1 ...) Returns multiple SMA-X entries from a table with metadata'
description='Returns multiple SMA-X entries from a table with metadata (table | key1 ...)'
}

redis.register_function{
function_name='smax_get_struct',
callback=smax_get_struct,
flags={ 'no-writes' },
description='(table) Returns an entire structure from SMA-X atomically with metadata'
description='Returns an entire structure from SMA-X atomically with metadata (table)'
}

redis.register_function{
function_name='smax_del',
callback=smax_del,
flags={},
description='Deletes a SMA-X ID, removing all references in parents and metadata alike'
description='Deletes a SMA-X ID, removing all references in parents and metadata alike (key1[,key2...]|)'
}

0 comments on commit f29ade3

Please sign in to comment.