# RedisPublish

Publishes a message to a Redis channel.

## Method Signature

```
RedisPublish(cacheName=[any], channel=[any], message=[any])
```

### Arguments

| Argument    | Type  | Required | Description                         | Default |
| ----------- | ----- | -------- | ----------------------------------- | ------- |
| `cacheName` | `any` | `true`   | The name of the redis cache to use. |         |
| `channel`   | `any` | `true`   | The channel name to publish to.     |         |
| `message`   | `any` | `true`   | The message to publish.             |         |

## Examples

Publish a message to a Redis channel:

```js
// Publish a simple message
var numSubscribers = RedisPublish(
    cache = "myRedisCache",
    channel = "notifications",
    message = "System update in progress"
);

println( "Message published to " & numSubscribers & " subscribers" );
```

Publish structured data as JSON:

```js
// Publish a structured message
var eventData = {
    type = "user.created",
    userId = 12345,
    timestamp = now()
};

var subscribers = RedisPublish(
    cache = "myRedisCache",
    channel = "events",
    message = serializeJSON( eventData )
);

println( "Event published to " & subscribers & " subscribers" );
```

## Related

* [RedisSubscribe()](/boxlang-+-++/modules/bx-redis/built-in-functions/redissubscribe.md) - Subscribe to Redis channels
* [RedisGetProvider()](/boxlang-+-++/modules/bx-redis/built-in-functions/redisgetprovider.md) - Get the Redis cache provider
* [Pub/Sub Patterns Guide](https://github.com/ortus-boxlang/boxlang-docs/blob/v1.x/boxlang-framework/boxlang-plus/modules/bx-redis/pub-sub-patterns.md) - Advanced publish/subscribe patterns
* [API Usage Guide](/boxlang-+-++/modules/bx-redis/api-usage.md) - Redis API documentation


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-+-++/modules/bx-redis/built-in-functions/redispublish.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
