SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 10/02/2017, 10:28 PM   #1
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,916
Reputation: 1460
Default Redis (cache, database and message queue)

Redis for SA:MP

A powerful Redis plugin granting access to a fast in-memory database and asynchronous message channels between other programs.

Itís open source and available here

What Redis Is

Quote:

Redis is an open source (BSD licensed), in-memory data structure store, used
as a database, cache and message broker. It supports data structures such as
strings, hashes, lists, sets, sorted sets with range queries, bitmaps,
hyperloglogs and geospatial indexes with radius queries.
(from the Redis official site)

In SA:MP terms: Redis is can be the GVar plugin on steroids. It can be a place to store large amounts of information and free up heap space (and cut compile times!)

You can also use Redis to delegate slower tasks to other programs through the power of pubsub message queues!

What Redis Is Not

Redis is not a permanent database. It exists entirely in memory which makes it very fast to read from and write to but it is not a replacement for something like MySQL to store data for a very long period of time.

Installation

Simply install to your project:

Code:
sampctl package install Southclaws/pawn-redis
Include in your code and begin using the library:

Code:
#include <pawn-redis>
__________________
Tools:

Plugins:

Links:


Last edited by [HLF]Southclaw; 21/05/2018 at 01:42 PM.
[HLF]Southclaw is online now   Reply With Quote
Old 10/02/2017, 10:42 PM   #2
BiosMarcel
High-roller
 
BiosMarcel's Avatar
 
Join Date: Jul 2012
Location: Germany
Posts: 1,232
Reputation: 221
Default Re: Redis (cache, database and message queue)

Awesome, definitely gonna use that sooner or later. 5 Start from me!

Edit: I said 5 stars and didn't rate, i am a genius

Last edited by BiosMarcel; 11/02/2017 at 09:59 AM.
BiosMarcel is offline   Reply With Quote
Old 10/02/2017, 10:56 PM   #3
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,420
Reputation: 1227
Default Re: Redis (cache, database and message queue)

That is pretty fucking cool the first thing that came to mind when I saw this was getting SA-MP servers to interact with other SA-MP servers.
Pottus is offline   Reply With Quote
Old 11/02/2017, 09:43 AM   #4
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,916
Reputation: 1460
Default Re: Redis (cache, database and message queue)

Quote:
Originally Posted by Pottus View Post
That is pretty fucking cool the first thing that came to mind when I saw this was getting SA-MP servers to interact with other SA-MP servers.
Yeah stuff like that will be much easier, I've also got a post in the works about cluster servers which you might find interesting too.

I'll hopefully get some code examples up today or soon.
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is online now   Reply With Quote
Old 11/02/2017, 09:45 AM   #5
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,981
Reputation: 451
Default Re: Redis (cache, database and message queue)

That's pretty useful (I was reading the source code in github and came back to forum ,the first thread was its release thread).
SyS is offline   Reply With Quote
Old 11/02/2017, 01:55 PM   #6
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,420
Reputation: 1227
Default Re: Redis (cache, database and message queue)

Quote:
Originally Posted by [HLF]Southclaw View Post
Yeah stuff like that will be much easier, I've also got a post in the works about cluster servers which you might find interesting too.

I'll hopefully get some code examples up today or soon.
I have not seen the material yet but right away my vision would be the ability to create dynamic servers on the fly then disconnect a player so they reconnect but re-route their connection to the port of the dynamic server.

"It only supports Linux and probably only ever will (unless someone gets Hiredis compiling on Windows!)"

I would highly recommend putting in copious amounts of effort to ensure cross-platform support my view is you will get maximum usage. Given that the majority of people doing any scripting use windows it just makes sense that you should really put in that time.

Last edited by Pottus; 02/07/2017 at 01:52 PM.
Pottus is offline   Reply With Quote
Old 11/02/2017, 03:30 PM   #7
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,916
Reputation: 1460
Default Re: Redis (cache, database and message queue)

I plan to give it a try on Windows and it could work since I'm only using a minimal portion of Hiredis (not the asynchronous part since I've used threading) so it might be possible. If not, it's likely going to require a completely different version of the plugin for Windows and I don't have much free time to be working on this stuff (linux version only took a few hours from start to finish, I'm mainly developing it for Scavenge and Survive tbh)
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is online now   Reply With Quote
Old 11/02/2017, 04:58 PM   #8
PrO.GameR
Gangsta
 
PrO.GameR's Avatar
 
Join Date: Oct 2012
Posts: 732
Reputation: 121
Default Re: Redis (cache, database and message queue)

I was looking forward to it, but now I'm kinda sad to see it not being supported for windows, my current setup is on windows and I will be having this VPS for a while now, so not really worth it for me to switch to another VPS to use this on the linux setup of the server.

Hope to see a windows version, I can already think of hundred possibilities I'm gonna use it for if I get the chance to.
__________________
Blueberry Prison Roleplay will be back soon!
Follow the forums for more information about opening day.

Forums
PrO.GameR is offline   Reply With Quote
Old 11/02/2017, 06:45 PM   #9
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Portugal
Posts: 7,186
Reputation: 775
Default Re: Redis (cache, database and message queue)

This is very very good to see.

nice work you did here

thanks for sharing.
__________________
"Quem caiu e se levantou honrado era e honrado ficou..."


CVU vai voltar e.e


http://steamcommunity.com/id/pt_player/
PT is offline   Reply With Quote
Old 12/02/2017, 11:08 AM   #10
isti37
Little Clucker
 
Join Date: May 2015
Posts: 1
Reputation: 0
Default Re: Redis (cache, database and message queue)

I have a friend working on a server and he aims for 1000 players and today I came back on this forum and got a nice suprise.

If we can make this client work with under 3ms 100% latency as in the benchmarks https://redis.io/topics/benchmarks one could theoretically split up a gamemode into multiple servers and sync the callbacks/data through redis to create a multithreaded and highly available system. Basically, you could round robin 4 servers on 4 different ips on different servers and sync all data through redis. If a server crashes the client just reconnects to another server in round robin because there is no state stored in the server.

Even if a single server is capable of only 1000 players, you could just sync in players from other servers with redis and do everything from chat to quests with redis messaging. Splitting the map to different servers to offload processing and maintaining one master to sync only the data from slaves would also be nice.
isti37 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redis cache and message queue plugin for SA:MP [HLF]Southclaw Discussion 2 06/02/2017 05:47 PM
Using Redis Misiur Discussion 3 11/08/2014 09:17 PM
Moderation Queue Syncro Screenshots and Videos 1 07/05/2014 11:57 AM
Queue iJumbo Discussion 13 06/08/2013 08:29 AM


All times are GMT. The time now is 05:59 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.