![]() ![]() But if you have objects with a large number of fields or nested objects, you’ll probably want to serialize them as JSON instead (and for this you’ll need the source-available RedisJSON module). We’re serializing this Customer object as a Redis hash, as it’s a simple object with a flat structure. With the Redis OM libraries, you can serialize your domain objects in two ways. Pass the unique ID to Customer.get(), and you’ll get your object back: In Python, you can access that unique ID with the pk property (pk, of course, refers to “primary key”). ![]() Want an example? A typical ULID looks like this: 01ARZ3NDEKTSV4RRFFQ69G5FAVĪnyway, once you’ve saved one of these objects to Redis, you can retrieve it by providing its unique ID. ULIDs are sortable, globally unique, URL-safe, and fairly human-readable when base32-encoded. You can think of a ULID as a kind of user-friendly UUID. For this, we’re using ULIDs (Universally Unique Lexicographically Sortable Identifiers). The Redis OM libraries automatically generate a unique ID for any new object. Now we create a new Customer instance like this:Īnd then we can write this new customer instance to Redis by calling save() on it: In this case, the object represents a customer: Object Mappingįirst, we can define a simple domain object. Since Python is a sort of lingua franca for us programmers, let’s explore a few examples from Redis OM for Python to get a sense of what’s possible here. What can I do with Redis OM?įor this first preview release, we focused on object mapping and fluent queries. The Redis OM libraries let you transparently persist your domain objects in Redis and query them using a fluent, language-centric API. If you’re modeling any domain, you’re likely representing that domain in an object-oriented fashion. The first abstraction we’re providing is object mapping. Our aim is to furnish you with a toolbox of high-level abstractions that make it easy to work with Redis data in the programming environments you call home. Redis OM (pronounced “ōm”) is object mapping (and more) for Redis. We’ve built (and continue to build) Redis OM so that you can get the performance of Redis even if you don’t have time to compose your own abstractions using the core data structures that Redis provides. Not everyone has the bandwidth to build their own rate limiter or to figure out how to map a Redis hash to Java class (and vice versa!). The challenge is that not everyone has the time to reinvent these tools on their own. This composability has allowed Redis users to create a wide variety of tools, including caches, distributed locks, message queues, rate limiters, pub/sub systems, background task executors, de-duplicators, and permissions systems, to name several. There’s a kind of Unix philosophy that runs through Redis: you can compose a well-built collection of primitives to solve any problem at hand. And, as we all know, Redis provides rock-solid, distributed data structures in spades. Just want a high-level overview for now? Read on! Why Redis OM?Īs programmers and CS geeks, we love the elegance of a good data structure. If you’re a software developer keen to see why we’re so excited about this launch, you can try one of our new libraries right now:Įach Redis OM library includes a comprehensive README and tutorial to help you get started quickly. Our goal is to make it as easy as possible to use Redis and the Redis modules from your applications. We’re calling these libraries Redis OM: Object Mapping, and more, for Redis. Today, we’re pleased to announce a preview release of four new high-level client libraries for Redis. Intuitive Object Mapping and Fluent Queries for Redis
0 Comments
Leave a Reply. |