# Source: https://upstash.com/docs/redis/sdks/ts/commands/functions/load.md

> ## Documentation Index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# FUNCTION LOAD

> Load a library to Redis.

Redis functions act as a superset of Lua scripts. Instead of sending the script
content with every request (like `EVAL`), you load the script once as a
"library" and call the functions it registers.

<Note>
  Currently, `LUA` is the only supported engine.
</Note>

The library source code must start with the `#!lua name=<library_name>` shebang.
Inside the script, use `redis.register_function` to expose your functions.

The registered functions can be called with the [FCALL](./call.mdx) command.

## Arguments

<ParamField body="options" type="Object" required>
  The load options.

  <Expandable>
    <ParamField body="code" type="string" required>
      The source code of the library.
    </ParamField>

    <ParamField body="replace" type="boolean" default="false">
      Whether to overwrite the library if it already exists. If `false` and the
      library already exists, Redis will return an error.
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField type="string" required>
  The name of the loaded library.
</ResponseField>

<RequestExample>
  ```ts Example theme={"system"}
  const code = `#!lua name=mylib
    
    -- Simple function that returns a string
    redis.register_function(
      'helloworld',
      function() return 'Hello World!' end
    )

    -- Complex function that modifies data with logic
    local function my_hset(keys, args)
      local hash = keys[1]
      local time = redis.call('TIME')[1]
      return redis.call('HSET', hash, '_last_modified_', time, unpack(args))
    end

    redis.register_function('my_hset', my_hset)
  `;

  const libraryName = await redis.functions.load({ code, replace: true });

  console.log(libraryName); // "mylib"
  ```
</RequestExample>