ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / Big Data / Managing REDIS databases
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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.
Example
INTERNAL PROCEDURE OnRedis(nType is int, sChannel is string, bufMessage is Buffer)
	SWITCH nType
		CASE redisSubscribe
			Trace("Subscription to " + sChannel) 
		CASE redisUnsubscribe
			Trace("Cancel subscription to " + sChannel) 
		CASE redisDisconnection
			Trace("Disconnection: " + sChannel)
		CASE redisMessage
			Trace("Message on " + sChannel+": " + UTF8ToString(bufMessage))
		OTHER CASE
			Trace("Unknown")
		END
	END

RedisSubscribe(gRedis, "MyChannel", 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: wd290big.dll
Minimum version required
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 04/12/2024

Send a report | Local help