Redis.OM
0.1.4
See the version list below for details.
dotnet add package Redis.OM --version 0.1.4
NuGet\Install-Package Redis.OM -Version 0.1.4
<PackageReference Include="Redis.OM" Version="0.1.4" />
paket add Redis.OM --version 0.1.4
#r "nuget: Redis.OM, 0.1.4"
// Install Redis.OM as a Cake Addin #addin nuget:?package=Redis.OM&version=0.1.4 // Install Redis.OM as a Cake Tool #tool nuget:?package=Redis.OM&version=0.1.4
<div align="center"> <br/> <br/> <img width="360" src="images/logo.svg" alt="Redis OM" /> <br/> <br/> </div>
<p align="center"> <p align="center"> Object mapping, and more, for Redis and .NET </p> </p>
Redis OM .NET makes it easy to model Redis data in your .NET Applications.
Redis OM .NET | Redis OM Node.js | Redis OM Spring | Redis OM Python
<details> <summary><strong>Table of contents</strong></summary>
- 💡 Why Redis OM?
- 💻 Installation
- 🏁 Getting started
- 📚 Documentation
- ⛏️ Troubleshooting
- ✨ RediSearch and RedisJSON
- ❤️ Contributing
- ❤️ Our Contributors
</details>
💡 Why Redis OM?
Redis OM provides high-level abstractions for using Redis in .NET, making it easy to model and query your Redis domain objects.
This preview release contains the following features:
- Declarative object mapping for Redis objects
- Declarative secondary-index generation
- Fluent APIs for querying Redis
- Fluent APIs for performing Redis aggregations
💻 Installation
Using the dotnet cli, run:
dotnet add package Redis.OM
🏁 Getting started
Starting Redis
Before writing any code you'll need a Redis instance with the appropriate Redis modules! The quickest way to get this is with Docker:
docker run -p 6379:6379 redislabs/redismod:preview
📇 Modeling your domain (and indexing it!)
With Redis OM, you can model your data and declare indexes with minimal code. For example, here's how we might model a customer object:
[Document]
public class Customer
{
[Indexed(Sortable = true)] public string FirstName { get; set; }
[Indexed(Aggregatable = true)] public string LastName { get; set; }
public string Email { get; set; }
[Indexed(Sortable = true)] public int Age { get; set; }
}
Notice that we've applied the Document
attribute to this class. We've also specified that certain fields should be Indexed
.
Now we need to create the Redis index. So we'll connect to Redis and then call CreateIndex
on an IRedisConnection
:
var provider = new RedisConnectionProvider("redis://localhost:6379");
provider.Connection.CreateIndex(typeof(Customer));
Once the index is created, we can:
- Insert Customer objects into Redis
- Get a Customer object by ID from Redis
- Query Customers from Redis
- Run aggregations on Customers in Redis
Let's see how!
🔎 Querying
We can query our domain using expressions in LINQ, like so:
var customers = provider.RedisCollection<Customer>();
// Insert customer
customers.Insert(new Customer()
{
FirstName = "James",
LastName = "Bond",
Age = 68,
Email = "[email protected]"
});
// Find all customers whose last name is "Bond"
customers.Where(x => x.LastName == "Bond");
// Find all customers whose last name is Bond OR whose age is greater than 65
customers.Where(x => x.LastName == "Bond" || x.Age > 65);
// Find all customers whose last name is Bond AND whose first name is James
customers.Where(x => x.LastName == "Bond" && x.FirstName == "James");
🖩 Aggregations
We can also run aggregations on the customer object, again using expressions in LINQ:
// Get our average customer age
customerAggregations.Average(x => x.RecordShell.Age);
// Format customer full names
customerAggregations.Apply(x => string.Format("{0} {1}", x.RecordShell.FirstName, x.RecordShell.LastName),
"FullName");
// Get each customer's distance from the Mall of America
customerAggregations.Apply(x => ApplyFunctions.GeoDistance(x.RecordShell.Home, -93.241786, 44.853816),
"DistanceToMall");
📚 Documentation
This README just scratches the surface. You can find a full tutorial on the Redis Developer Site. All the summary docs for this library can be found on the repo's github page.
⛏️ Troubleshooting
If you run into trouble or have any questions, we're here to help!
First, check the FAQ. If you don't find the answer there, hit us up on the Redis Discord Server.
✨ RedisJSON
Redis OM can be used with regular Redis for Object mapping and getting objects by their IDs. For more advanced features like indexing, querying, and aggregation, Redis OM is dependeant on the Source Available RedisJSON module.
Why this is important
Without RedisJSON, you can still use Redis OM to create declarative models backed by Redis.
We'll store your model data in Redis as Hashes, and you can retrieve models using their primary keys.
So, what won't work without these modules?
- You won't be able to nest models inside each other.
- You won't be able to use our expressive queries to find object -- you'll only be able to query by primary key.
So how do you get RedisJSON?
You can use RedisJSON with your self-hosted Redis deployment. Just follow the instructions on installing the binary version of the module in its Quick Start Guides.
NOTE: The quick start guide has instructions on how to run the module in Redis with Docker.
Don't want to run Redis yourself? RedisJSON is also available on Redis Cloud. Get started here.
❤️ Contributing
We'd love your contributions! If you want to contribute please read our Contributing document.
❤️ Our Contributors
- @slorello89
- @banker
- @simonprickett
- @BenShapira
- @satish860
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 5.0.0)
- Newtonsoft.Json (>= 13.0.1)
- StackExchange.Redis (>= 2.2.50)
- System.Text.Json (>= 5.0.2)
- Ulid (>= 1.2.6)
NuGet packages (15)
Showing the top 5 NuGet packages that depend on Redis.OM:
Package | Downloads |
---|---|
ShayganTadbir.Framework.Core
Package description |
|
FCMicroservices
a boilerplate microservice framework |
|
BSN.Commons
Commons library for enterprise application |
|
Redis.OM.Vectorizers.AllMiniLML6V2
Sentence Vectorizer for Redis OM .NET using all-MiniLM-L6-v2 |
|
Dofus.Framework
Package Description |
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on Redis.OM:
Repository | Stars |
---|---|
eventflow/EventFlow
Async/await first CQRS+ES and DDD framework for .NET
|
|
redis/redis-om-dotnet
Object mapping, and more, for Redis and .NET
|
|
LBPUnion/ProjectLighthouse
Project Lighthouse is a clean-room, open-source custom server for LittleBigPlanet.
|
|
SapiensAnatis/Dawnshard
Server emulator for Dragalia Lost
|
Version | Downloads | Last updated |
---|---|---|
0.7.6 | 3,221 | 10/28/2024 |
0.7.5 | 9,011 | 10/4/2024 |
0.7.4 | 30,650 | 7/15/2024 |
0.7.3 | 3,252 | 7/12/2024 |
0.7.2 | 874 | 7/11/2024 |
0.7.1 | 50,860 | 5/2/2024 |
0.7.0 | 25,395 | 4/12/2024 |
0.6.1 | 117,256 | 12/6/2023 |
0.6.0 | 11,070 | 12/5/2023 |
0.5.5 | 5,552 | 11/27/2023 |
0.5.4 | 33,989 | 10/26/2023 |
0.5.3 | 101,266 | 8/16/2023 |
0.5.2 | 89,749 | 5/16/2023 |
0.5.1 | 10,893 | 5/3/2023 |
0.5.0 | 8,000 | 4/14/2023 |
0.4.2 | 73,701 | 3/14/2023 |
0.4.1 | 47,878 | 1/13/2023 |
0.4.0 | 31,122 | 12/12/2022 |
0.3.1 | 54,177 | 10/13/2022 |
0.3.0 | 1,212 | 10/11/2022 |
0.2.3 | 72,066 | 9/19/2022 |
0.2.1 | 70,794 | 7/19/2022 |
0.2.0 | 5,096 | 7/5/2022 |
0.1.9 | 38,927 | 4/1/2022 |
0.1.8 | 4,238 | 3/1/2022 |
0.1.7 | 1,178 | 2/9/2022 |
0.1.6 | 1,770 | 2/4/2022 |
0.1.5 | 515 | 1/31/2022 |
0.1.4 | 1,783 | 12/13/2021 |
0.1.3 | 713 | 12/7/2021 |
0.1.2 | 371 | 11/29/2021 |
0.1.1 | 6,221 | 11/24/2021 |
0.1.0 | 398 | 11/18/2021 |