# 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()](https://boxlang.ortusbooks.com/boxlang-framework/boxlang-plus/modules/bx-redis/reference/built-in-functions/redissubscribe) - Subscribe to Redis channels
* [RedisGetProvider()](https://boxlang.ortusbooks.com/boxlang-framework/boxlang-plus/modules/bx-redis/reference/built-in-functions/redisgetprovider) - 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](https://boxlang.ortusbooks.com/boxlang-framework/boxlang-plus/modules/bx-redis/api-usage) - Redis API documentation
