Documentation on using Redis Brain
See original GitHub issueIs there some more detailed documentation on using the Hubot redis brain effectively, or good practices for it?
For example, the scripting docs (https://github.com/github/hubot/blob/f672bc03cf4bf415ce45ed60c38334d988fae8f4/docs/scripting.md) simply talk about storing and retrieving key-value strings.
However, if you look at scripts like this:
They use more slightly more complex structures (arrays, dicts etc.) - I assume these just get stringified, then stored in redis:
teams = []
for key, teamData of @store()
continue if key is @defaultName()
teams.push new Team(teamData.name, teamData.members)
teams
They also seem to namespace things as follows (which I’d hadn’t realised you could do until I saw this):
@robot.brain.data.teams or= {}
It’d be nice if there were more examples of the redis-brain in action, or even just pointers to good example scripts where we can see good practices for these things?
Issue Analytics
- State:
- Created 8 years ago
- Comments:5
Top Results From Across the Web
hubot-redis-brain: Documentation | Openbase
hubot-redis-brain. A hubot script to persist hubot's brain using redis. See src/redis-brain.coffee for full documentation.
Read more >Redis cluster specification
Welcome to the Redis Cluster Specification. Here you'll find information about the algorithms and design rationales of Redis Cluster. This document is a...
Read more >hubot-redis-brain-docker - npm package | Snyk
A hubot script to persist hubot's brain using redis in docker For more information about how to use ... See src/redis-brain.coffee for full...
Read more >jubot.brain documentation
Get data from system brain. Before using this function, jubot.system should be started. Params k - Data key. Return Stored data.
Read more >hubot - Replacing local redis server with a ... - Stack Overflow
'use strict' // Description: // Persist hubot's brain to redis ... else { robot.logger.info('hubot-redis-brain: Using default redis on ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Given the way that persistence works, you can actually just maintain a pointer to an object in the brain, manipulate it all you want, and it will be persisted every
saveInterval
. So, in code:Hmm, but if you use
get
/set
, how do you store more complex data structures?For example, say you have an array:
Or something like this:
(These are somewhat contrived examples, I know).
How should you push/pop individual items to this, assuming it’s been set in the redis brain?
Do you pull the whole thing out into a variable, edit it, then set the whole thing back? Or is there a better way, using get/set?