ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / Big Data / Managing REDIS databases
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Subscribes to a Redis broadcast channel. The application will then be notified about messages sent by applications connected to the Redis server that publishes messages on that channel.
New in version 2025
This function can also be used to manipulate data on a Valkey server.
Example
INTERNAL PROCEDURE OnRedis(nType is int, sChannel is string, bufMessage is Buffer)
	SWITCH nType
		CASE redisSubscribe
			Trace("Abonnement à " + sChannel) 
		CASE redisUnsubscribe
			Trace("Désabonnement à " + sChannel) 
		CASE redisDisconnection
			Trace("Déconnexion : " + sChannel)
		CASE redisMessage
			Trace("Message sur " + sChannel+" : " + UTF8ToString(bufMessage))
		OTHER CASE
			Trace("Inconnu")
		END
	END

RedisSubscribe(gRedis, "MonCanal", OnRedis)
Syntax
<Result> = RedisSubscribe(<Connection> , <Channel> , <WLanguage procedure>)
<Result>: Boolean
  • True is successfully subscribed,
  • False otherwise.
<Connection>: redisConnection variable
Name of the redisConnection variable that corresponds to the Redis server connection.
<Channel>: Character string
Name of the broadcast channel to which it is necessary to subscribe in order to receive messages.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called:
  • when a message is received,
  • when subscribing,
  • when unsubscribing,
  • when disconnecting.
This procedure makes it possible to manage the current message. It will be called in a specific thread.
This procedure has the following format:
PROCEDURE <Procedure name>(<Type>, <Subscription channel>, <Message>)

  • <Type> contains the type of message. This parameter corresponds to one of the following constants:
    redisDisconnectionThe connection to the Redis server has been lost.
    If the procedure returns False, the application loses its subscription. Otherwise, the application will try to reconnect to the Redis server.
    redisMessageThe application has just received a message. In this case, <Message> contains the body of the message.
    redisSubscription The application has just subscribed to <Subscription channel>.
    redisUnsubscribeThe application has just unsubscribed from <Subscription channel>.
  • <Subscription channel> is a character string that contains the name of the channel to which the application subscribed.
  • <Message> is a buffer that corresponds to the content of the message.
Business / UI classification: Business Logic
Component: wd300big.dll
Minimum version required
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help