-
Notifications
You must be signed in to change notification settings - Fork 47
pipeline examples #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shacharPash
merged 13 commits into
redis:examples
from
Jeevananthan-23:NRedisStackExamples
Feb 5, 2023
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b428b8d
Merge branch 'redis:master' into NRedisStackExamples
Jeevananthan-23 c3ffd36
added pipelineexamples and docs
Jeevananthan-23 262d5dc
Merge branch 'redis:master' into NRedisStackExamples
Jeevananthan-23 3185e11
Merge branch 'examples' into NRedisStackExamples
Jeevananthan-23 e8fa4f0
adding pipelinewithAsync example
Jeevananthan-23 1c26a8c
Adding a README to the nuget package (#76)
chayim 7ee38b6
adding pipelinewithasync doc feedback changes
Jeevananthan-23 3ecd26c
feedback changes
Jeevananthan-23 895762f
fix examples
shacharPash 97cdcf7
Merge branch 'redis:master' into NRedisStackExamples
Jeevananthan-23 ae7dccf
fix JsonWithSearchPipeline test
shacharPash ec67b47
Add delay before search
shacharPash 0803d30
Change to one consractor for Pipeline that get IDatabase
shacharPash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Combination modules Pipeline | ||
## An example of pipelines mixing a pipeline with a combination of module commands with JSON & Search | ||
|
||
### Connect to the Redis server: | ||
```csharp | ||
var redis = ConnectionMultiplexer.Connect("localhost"); | ||
``` | ||
|
||
### Setup pipeline connection | ||
```csharp | ||
var pipeline = new Pipeline(ConnectionMultiplexer.Connect("localhost")); | ||
``` | ||
|
||
### Add JsonSet to pipeline | ||
```csharp | ||
pipeline.Json.SetAsync("person:01", "$", new { name = "John", age = 30, city = "New York" }); | ||
pipeline.Json.SetAsync("person:02", "$", new { name = "Joy", age = 25, city = "Los Angeles" }); | ||
pipeline.Json.SetAsync("person:03", "$", new { name = "Mark", age = 21, city = "Chicago" }); | ||
pipeline.Json.SetAsync("person:04", "$", new { name = "Steve", age = 24, city = "Phoenix" }); | ||
pipeline.Json.SetAsync("person:05", "$", new { name = "Michael", age = 55, city = "San Antonio" }); | ||
``` | ||
|
||
### Create the schema to index first and age as a numeric field | ||
```csharp | ||
var schema = new Schema().AddTextField("name").AddNumericField("age", true).AddTagField("city"); | ||
``` | ||
|
||
### Filter the index to only include Jsons and prefix of person | ||
```csharp | ||
var parameters = FTCreateParams.CreateParams().On(Literals.Enums.IndexDataType.JSON).Prefix("person:"); | ||
``` | ||
|
||
### Create the index via pipeline | ||
```csharp | ||
pipeline.Ft.CreateAsync("person-idx", parameters, schema); | ||
``` | ||
|
||
### Search for all indexed person records | ||
```csharp | ||
var getAllPersons = pipeline.Ft.SearchAsync("person-idx", new Query()); | ||
Jeevananthan-23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### Execute the pipeline | ||
```csharp | ||
pipeline.Execute(); | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Pipeline | ||
## An example of pipelines Redis Stack Redis commands (JSON.SET & JSON.CLEAR & JSON.GET) | ||
|
||
### Connect to the Redis server: | ||
Jeevananthan-23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```csharp | ||
var redis = ConnectionMultiplexer.Connect("localhost"); | ||
``` | ||
|
||
### Setup pipeline connection | ||
```csharp | ||
var pipeline = new Pipeline(ConnectionMultiplexer.Connect("localhost")); | ||
Jeevananthan-23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### Add JsonSet to pipeline | ||
```csharp | ||
pipeline.Json.SetAsync("person", "$", new { name = "John", age = 30, city = "New York", nicknames = new[] { "John", "Johny", "Jo" } }); | ||
``` | ||
|
||
### Inc age by 2 | ||
```csharp | ||
pipeline.Json.NumIncrbyAsync("person", "$.age", 2); | ||
``` | ||
|
||
### Clear the nicknames from the Json | ||
```csharp | ||
pipeline.Json.ClearAsync("person", "$.nicknames"); | ||
``` | ||
|
||
### Del the nicknames | ||
```csharp | ||
pipeline.Json.DelAsync("person", "$.nicknames"); | ||
``` | ||
|
||
### Get the Json response | ||
```csharp | ||
var getResponse = pipeline.Json.GetAsync("person"); | ||
``` | ||
|
||
### Execute the pipeline | ||
```csharp | ||
pipeline.Execute(); | ||
``` | ||
Jeevananthan-23 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.