Skip to content

Commit c330e23

Browse files
author
arthosofteq
authored
Merge pull request #1 from RedisInsight/feature/RI-2450_add_tutorials
Feature/ri 2450 add tutorials
2 parents 7be5a43 + 6fcc950 commit c330e23

7 files changed

+1320
-0
lines changed

src/_scripts/manual.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Workbench is the advanced Redis command-line interface that allows to send commands to Redis, read and visualize the replies sent by the server.
2+
// Enter multiple commands at different rows to run them at once.
3+
// Start a new line with an indent (Tab) to specify arguments for any Redis command in multiple line mode.
4+
// Use F1 to see the full list of shortcuts available in Workbench.
5+
// Use Ctrl+Space (Cmd+Space) to see the list of commands and information about commands and their arguments in the suggestion list.
6+
// Use Ctrl+Shift+Space (Cmd+Shift+Space) to see the list of arguments for commands.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
In very broad terms probabilistic data structures (PDS) allow us to get to a "close enough" result in a much shorter time and by using significantly less memory.
2+
3+
Redis Stack supports 4 of the most famous PDS:
4+
- Bloom filters
5+
- Cuckoo filters
6+
- Count-Min Sketch
7+
- Top-K
8+
9+
In the rest of this tutorial we'll introduce how you can use a Bloom filter to save many heavy calls to the relational database, or a lot of memory, compared to using sets or hashes.
10+
A Bloom filter is a probabilistic data structure that enables you to check if an element is present in a set using a very small memory space of a fixed size. **It can guarantee the absence of an element from a set, but it can only give an estimation about its presence**. So when it responds that an element is not present in a set (a negative answer), you can be sure that indeed is the case. However, one out of every N positive answers will be wrong.
11+
Even though it looks unusual at a first glance, this kind of uncertainty still has its place in computer science. There are many cases out there where a negative answer will prevent very costly operations;
12+
13+
How can a Bloom filter be useful to our bike shop? For starters, we could keep a Bloom filter that stores all usernames of people who've already registered with our service. That way, when someone is creating a new account we can very quickly check if that username is free. If the answer is yes, we'd still have to go and check the main database for the precise result, but if the answer is no, we can skip that call and continue with the registration.
14+
15+
Another, perhaps more interesting example is for showing better and more relevant ads to users. We could keep a bloom filter per user with all the products they've bought from the shop, and when we get a list of products from our suggestion engine we could check it against this filter.
16+
17+
18+
```redis Add all bought product ids in the Bloom filter
19+
BF.MADD user:778:bought_products 4545667 9026875 3178945 4848754 1242449
20+
```
21+
22+
Just before we try to show an ad to a user, we can first check if that product id is already in their "bought products" Bloom filter. If the answer is yes - we might choose to check the main database, or we might skip to the next recommendation from our list. But if the answer is no, then we know for sure that our user hasn't bought that product:
23+
24+
```redis Has a user bought this product?
25+
BF.EXISTS user:778:bought_products 1234567 // No, the user has not bought this product
26+
BF.EXISTS user:778:bought_products 3178945 // The user might have bought this product
27+
```

0 commit comments

Comments
 (0)