You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We recommend using docker to start a local Redis instance for testing. Setting up a production-level Redis instance is out of the scope of this documentation.
$ docker run -d -p 127.0.0.1:6379:6379 redis:4-alpine
Create a project.
Open up a terminal and create a new console project to get started.
$ mkdir myProject &&cd myProject
$ dotnet new console
Add the Gofer.NET NuGet package.
$ dotnet add package Gofer.NET --version 1.0.0-*
Queue up some jobs.
This example Program.cs shows how to queue jobs for the worker pool to process, then start a worker to go and run them.
Some important notes:
Workers would usually be on a separate machine from the code queueing the jobs, this is purely to give an example.
More workers can be added at any time, and will start picking up jobs off the queue immediately.
publicclassProgram{publicstaticasyncTaskMain(string[]args){varredisConnectionString="127.0.0.1:6379";// Create a Task Client connected to RedisvartaskClient=newTaskClient(TaskQueue.Redis(redisConnectionString));// Queue up a Sample JobawaittaskClient.TaskQueue.Enqueue(()=>SampleJobFunction("Hello World!"));// Start the task listener, effectively turning this process into a worker.// NOTE: This will loop endlessly waiting for new tasks.awaittaskClient.Listen();}privatestaticvoidSampleJobFunction(objectvalue){Console.WriteLine(value.ToString());}}