# SCRIPT LOAD

> Compile a Lua script and add it to the script cache without running it.

URL: https://docs.hotkv.com/commands/script-load/

```
SCRIPT LOAD script
```

- Group: Scripting and functions
- Complexity: O(N) where N is the length of the script
- HotKV Cloud: all plans
- On-Premise: no license needed

`SCRIPT LOAD` compiles `script`, stores it in the script cache and returns its
SHA1 digest, which you then pass to [EVALSHA](https://docs.hotkv.com/commands/evalsha/index.md). Loading the
same text again returns the same digest. Scripts loaded this way stay cached
until [SCRIPT FLUSH](https://docs.hotkv.com/commands/script-flush/index.md) or a restart.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Compiled | Bulk string: the 40-character hexadecimal SHA1 digest | Bulk string |

Errors:

- `ERR Error compiling script (new function): ...` when the script does not
  compile.
- `ERR Invalid script shebang`, `ERR Unknown lua shebang option: ...` and
  `ERR Unexpected flag in script shebang: ...` for a bad shebang line.

## Examples

```
127.0.0.1:6379> SCRIPT LOAD "return redis.call('GET', KEYS[1])"
"d3c21d0c2b9ca22f82737626a27bcaf5d288f99f"
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[EVALSHA](https://docs.hotkv.com/commands/evalsha/index.md), [SCRIPT EXISTS](https://docs.hotkv.com/commands/script-exists/index.md),
[SCRIPT FLUSH](https://docs.hotkv.com/commands/script-flush/index.md)