Redis ( / ˈ r ɛ d ɪ s / ; Remote Dictionary Server ) is a source-available , in-memory storage, used as a distributed , in-memory key–value database , cache and message broker , with optional durability . Because it holds all data in memory and because of its design, Redis offers low- latency reads and writes, making it particularly suitable for use cases that require a cache. Redis is the most popular NoSQL database, and one of the most popular databases overall. Redis is used in companies like Twitter , Airbnb , Tinder , Yahoo , Adobe , Hulu , Amazon and OpenAI .
70-427: Redis supports different kinds of abstract data structures , such as strings , lists , maps , sets , sorted sets, HyperLogLogs , bitmaps , streams , and spatial indices . The project was developed and maintained by Salvatore Sanfilippo, starting in 2009. From 2015 until 2020, he led a project core team sponsored by Redis Labs . Salvatore Sanfilippo left Redis as the maintainer in 2020. In 2021 Redis Labs dropped
140-514: A binary dump, using the Redis RDB Dump File Format. Alternatively by journaling , where a record of each operation that modifies the dataset is added to an append -only file (AOF) in a background process. Redis can rewrite the append-only file in the background to avoid an indefinite growth of the journal. Journaling was introduced in version 1.1 and is generally considered the safer approach. By default, Redis writes data to
210-435: A certain result, or left unspecified. There are some algorithms whose efficiency depends on the assumption that such a fetch is legal, and returns some arbitrary value in the variable's range. An abstract stack is a last-in-first-out structure, It is generally defined by three key operations: push , that inserts a data item onto the stack; pop , that removes a data item from it; and peek or top , that accesses
280-458: A computer, integers are most commonly represented as fixed-width 32-bit or 64-bit binary numbers . Users must be aware of issues with this representation, such as arithmetic overflow , where the ADT specifies a valid result but the representation is unable to accommodate this value. Nonetheless, for many purposes, the user can ignore these infidelities and simply use the implementation as if it were
350-409: A data item on top of the stack without removal. A complete abstract stack definition includes also a Boolean -valued function empty ( S ) and a create () operation that returns an initial stack instance. In the axiomatic semantics, letting S {\displaystyle S} be the type of stack states and X {\displaystyle X} be the type of values contained in
420-474: A different state) or circular stacks (that return to the same state after a finite number of pop s). In particular, they do not exclude states s such that pop ( s ) = s or push ( s , x ) = s for some x . However, since one cannot obtain such stack states from the initial stack state with the given operations, they are assumed "not to exist". In the operational definition of an abstract stack, push ( S , x ) returns nothing and pop ( S ) yields
490-580: A file system at least every 2 seconds, with more or less robust options available if needed. In the case of a complete system failure on default settings, only a few seconds of data would be lost. Redis supports master–replica replication . Data from any Redis server can replicate to any number of replicas. A replica may be a master to another replica. This allows Redis to implement a single-rooted replication tree. Redis replicas can be configured to accept writes, permitting intentional and unintentional inconsistency between instances. The publish–subscribe feature
560-558: A hidden representation. In this model, an ADT is typically implemented as a class , and each instance of the ADT is usually an object of that class. The module's interface typically declares the constructors as ordinary procedures, and most of the other ADT operations as methods of that class. Many modern programming languages, such as C++ and Java, come with standard libraries that implement numerous ADTs in this style. However, such an approach does not easily encapsulate multiple representational variants found in an ADT. It also can undermine
630-536: A managed Redis service called ElastiCache for Redis, Google offers a managed Redis service called Cloud Memorystore, Microsoft offers Azure Cache for Redis in Azure , and Alibaba offers ApsaraDB for Redis in Alibaba Cloud . Redis is being used in companies like Twitter, AirBnB, Tinder, Yahoo, Adobe, Hulu, and Amazon. Abstract data structures In computer science , an abstract data type ( ADT )
700-528: A theoretical concept, used in formal semantics and program verification and, less strictly, in the design and analysis of algorithms , data structures , and software systems . Most mainstream computer languages do not directly support formally specifying ADTs. However, various language features correspond to certain aspects of implementing ADTs, and are easily confused with ADTs proper; these include abstract types , opaque data types , protocols , and design by contract . For example, in modular programming ,
770-632: A transaction committed. Redis operates as a single process and is single-threaded or double-threaded when it rewrites the AOF (append-only file). Thus, a single Redis instance cannot use parallel execution of tasks such as stored procedures . Redis introduced clustering in April 2015 with the release of version 3.0. The cluster specification implements a subset of Redis commands: all single-key commands are available, multi-key operations (commands related to unions and intersections) are restricted to keys belonging to
SECTION 10
#1732793784177840-400: A user. For example, a stack has push/pop operations that follow a Last-In-First-Out rule, and can be concretely implemented using either a list or an array. Another example is a set which stores values, without any particular order , and no repeated values. Values themselves are not retrieved from sets; rather, one tests a value for membership to obtain a Boolean "in" or "not in". ADTs are
910-406: Is a mathematical model for data types , defined by its behavior ( semantics ) from the point of view of a user of the data, specifically in terms of possible values, possible operations on data of this type, and the behavior of these operations. This mathematical model contrasts with data structures , which are concrete representations of data, and are the point of view of an implementer, not
980-433: Is a separate entity or value. In this view, each operation is modelled as a mathematical function with no side effects . Operations that modify the ADT are modeled as functions that take the old state as an argument and returns the new state as part of the result. The order in which operations are evaluated is immaterial, and the same operation applied to the same arguments (including the same input states) will always return
1050-452: Is an implementation of the abstract stack above in the C programming language . An imperative-style interface might be: This interface could be used in the following manner: This interface can be implemented in many ways. The implementation may be arbitrarily inefficient, since the formal definition of the ADT, above, does not specify how much space the stack may use, nor how long each operation should take. It also does not specify whether
1120-413: Is customary to assume also that the stack states are only those whose existence can be proved from the axioms in a finite number of steps. In this case, it means that every stack is a finite sequence of values, that becomes the empty stack (Λ) after a finite number of pop s. By themselves, the axioms above do not exclude the existence of infinite stacks (that can be pop ped forever, each time yielding
1190-557: Is empty), empty ( push ( S , x )) = F (pushing something into a stack makes it non-empty). These axioms do not define the effect of top ( s ) or pop ( s ), unless s is a stack state returned by a push . Since push leaves the stack non-empty, those two operations can be defined to be invalid when s = Λ. From these axioms (and the lack of side effects), it can be deduced that push (Λ, x ) ≠ Λ. Also, push ( s , x ) = push ( t , y ) if and only if x = y and s = t . As in some other branches of mathematics, it
1260-430: Is fully implemented, so a client of a replica may subscribe to a channel and receive a full feed of messages published to the master, anywhere up the replication tree. Replication is useful for read (but not write) scalability or data redundancy. When the durability of data is not needed, the in-memory nature of Redis allows it to perform well compared to database systems that write every change to disk before considering
1330-447: Is implicitly assumed that names are always distinct: storing a value into a variable U has no effect on the state of a distinct variable V . To make this assumption explicit, one could add the constraint that: This definition does not say anything about the result of evaluating fetch ( V ) when V is un-initialized , that is, before performing any store operation on V . Fetching before storing can be disallowed, defined to have
1400-430: Is not normally relevant or meaningful, since ADTs are theoretical entities that do not "use memory". However, it may be necessary when one needs to analyze the storage used by an algorithm that uses the ADT. In that case, one needs additional axioms that specify how much memory each ADT instance uses, as a function of its state, and how much of it is returned to the pool by free . The definition of an ADT often restricts
1470-516: Is often defined implicitly, for example the free object over the set of ADT operations. The interface of the ADT typically refers only to the domain and operations, and perhaps some of the constraints on the operations, such as pre-conditions and post-conditions; but not to other constraints, such as relations between the operations, which are considered behavior. There are two main styles of formal specifications for behavior, axiomatic semantics and operational semantics . Despite not being part of
SECTION 20
#17327937841771540-441: Is that Redis supports not only strings , but also abstract data types: The type of a value determines what operations (called commands) are available for the value. Redis supports high-level, atomic, server-side operations like intersection, union, and difference between sets and sorting of lists, sets and sorted sets. More data types are supported based on Redis Modules API. Note, that some of them are dual licensed, and not under
1610-511: Is very unusual compared to a relational database management system (RDBMS). User commands do not describe a query to be executed by the database engine but rather specific operations that are performed on given abstract data types. Therefore data must be stored in a way which is suitable later for fast retrieval. The retrieval is done without help from the database system in form of secondary indexes, aggregations or other common features of traditional RDBMS. The Redis implementation makes heavy use of
1680-411: The push ( S , x ). From this condition and from the properties of abstract variables, it follows, for example, that the sequence: where x , y , and z are any values, and U , V , W are pairwise distinct variables, is equivalent to: Unlike the axiomatic semantics, the operational semantics can suffer from aliasing. Here it is implicitly assumed that operations on a stack instance do not modify
1750-445: The fork system call, to duplicate the process holding the data, so that the parent process continues to serve clients while the child process writes the in-memory data to disk. According to monthly DB-Engines rankings , Redis is often the most popular key–value database . Redis has also been ranked the #4 NoSQL database in user satisfaction and market presence based on user reviews, the most popular NoSQL database in containers, and
1820-469: The type systems of programming languages. However, an ADT may be implemented . This means each ADT instance or state is represented by some concrete data type or data structure , and for each abstract operation there is a corresponding procedure or function , and these implemented procedures satisfy the ADT's specifications and axioms up to some standard. In practice, the implementation is not perfect, and users must be aware of issues due to limitations of
1890-948: The #4 Data store of 2019 by ranking website stackshare.io. It was voted most loved database in the Stack Overflow Developer Survey each year from 2017 to 2021. Since version 2.6, Redis features server-side scripting in the language Lua . Many programming languages have Redis language bindings on the client side, including: ActionScript , C , C++ , C# , Chicken , Clojure , Common Lisp , Crystal , D , Dart , Delphi , Elixir , Erlang , Go , Haskell , Haxe , Io , Java , Nim , JavaScript ( Node.js ), Julia , Lua , Objective-C , OCaml , Perl , PHP , Pure Data , Python , R , Racket , Ruby , Rust , Scala , Smalltalk , Swift , and Tcl . Several client software programs exist in these languages. Redis maps keys to types of values. An important difference between Redis and other structured storage systems
1960-448: The ADT. This provides a form of abstraction or encapsulation, and gives a great deal of flexibility when using ADT objects in different situations. For example, different implementations of the ADT may be more efficient in different situations; it is possible to use each in the situation where they are preferable, thus increasing overall efficiency. Code that uses an ADT implementation according to its interface will continue working even if
2030-553: The BSD 3 clause: Former implementations include: Redis typically holds the whole dataset in memory. Versions up to 2.4 could be configured to use what they refer to as virtual memory in which some of the dataset is stored on disk, but this feature is deprecated. Persistence in Redis can be achieved through two different methods. First by snapshotting, where the dataset is asynchronously transferred from memory to disk at regular intervals as
2100-673: The Labs from its name and now is known simply as "Redis". In 2018, some modules for Redis adopted the SSPL . In 2024, the main Redis code switched to dual-licensed under the Redis Source Available License v2 and the Server Side Public License v1. The name Redis means Remote Dictionary Server. The Redis project began when Salvatore Sanfilippo, nicknamed antirez , the original developer of Redis,
2170-409: The Redis database. Redis popularized the idea of a system that can be considered a store and a cache at the same time. It was designed so that data is always modified and read from the main computer memory, but also stored on disk in a format that is unsuitable for random data access. The formatted data is only reconstructed into memory once the system restarts. Redis also provides a data model that
Redis - Misplaced Pages Continue
2240-409: The abstract data type. Usually, there are many ways to implement the same ADT, using several different concrete data structures. Thus, for example, an abstract stack can be implemented by a linked list or by an array . Different implementations of the ADT, having all the same properties and abilities, can be considered semantically equivalent and may be used somewhat interchangeably in code that uses
2310-448: The array size). Functional-style ADT definitions are more appropriate for functional programming languages, and vice versa. However, one can provide a functional-style interface even in an imperative language like C. For example: DB-Engines ranking The DB-Engines Ranking ranks database management systems by popularity, covering over 410 systems. The ranking criteria include number of search engine results when searching for
2380-591: The arrays in many scripting languages, such as Awk , Lua , and Perl , which can be regarded as an implementation of the abstract list. In a formal specification language , ADTs may be defined axiomatically, and the language then allows manipulating values of these ADTs, thus providing a straightforward and immediate implementation. The OBJ family of programming languages for instance allows defining equations for specification and rewriting to run them. Such automatic implementations are usually not as efficient as dedicated implementations, however. As an example, here
2450-550: The assets of DB-Engines were bought by Redgate Software. Redgate stated that it would retain the DB-Engines branding and identity and continue to provide trusted and independent monthly database ranking reports. The DB-Engines DBMS portal was created in 2012 and is maintained by the Austrian consulting company Solid IT. Based on its ranking, DB-Engines grants a yearly award for the system that gained most in popularity within
2520-550: The axiomatic semantics, creating the initial stack is a "trivial" operation, and always returns the same distinguished state. Therefore, it is often designated by a special symbol like Λ or "()". The empty operation predicate can then be written simply as s = Λ {\displaystyle s=\Lambda } or s ≠ Λ {\displaystyle s\neq \Lambda } . The constraints are then pop(push(S,v))=(S,v) , top(push(S,v))=v , empty ( create ) = T (a newly created stack
2590-422: The concrete data structure used—can then be hidden from most clients of the module. This makes it possible to change the implementation without affecting the clients. If the implementation is exposed, it is known instead as a transparent data type. Modern object-oriented languages, such as C++ and Java , support a form of abstract data types. When a class is used as a type, it is an abstract type that refers to
2660-574: The definition of an abstract variable to include abstract records , operations upon a field F of a record variable R , clearly involve F , which is distinct from, but also a part of, R . A partial aliasing axiom would state that changing a field of one record variable does not affect any other records. Some authors also include the computational complexity ("cost") of each operation, both in terms of time (for computing operations) and space (for representing values), to aid in analysis of algorithms . For example, one may specify that each operation takes
2730-529: The development of the CLU language. Algebraic specification was an important subject of research in CS around 1980 and almost a synonym for abstract data types at that time. It has a mathematical foundation in universal algebra . Formally, an ADT is analogous to an algebraic structure in mathematics, consisting of a domain, a collection of operations, and a set of constraints the operations must satisfy. The domain
2800-433: The difference in operation costs, and that an ADT specification should be independent of implementation. An abstract variable may be regarded as the simplest non-trivial ADT, with the semantics of an imperative variable. It admits two operations, fetch and store . Operational definitions are often written in terms of abstract variables. In the axiomatic semantics, letting V {\displaystyle V} be
2870-465: The extensibility of object-oriented programs. In a pure object-oriented program that uses interfaces as types, types refer to behaviours, not representations. The specification of some programming languages is intentionally vague about the representation of certain built-in data types, defining only the operations that can be done on them. Therefore, those types can be viewed as "built-in ADTs". Examples are
Redis - Misplaced Pages Continue
2940-442: The four data types can then be given by successively adding the following rules over these operations: Access to the data can be specified by pattern-matching over the three operations, e.g. a member function for these containers by: Care must be taken to ensure that the function is invariant under the relevant rules for the data type. Within each of the equivalence classes implied by the chosen subset of equations, it has to yield
3010-419: The imperative style often used when describing abstract algorithms. The constraints are typically specified in prose. Presentations of ADTs are often limited in scope to only key operations. More thorough presentations often specify auxiliary operations on ADTs, such as: These names are illustrative and may vary between authors. In imperative-style ADT definitions, one often finds also: The free operation
3080-399: The implementation of the ADT is changed. In order to prevent clients from depending on the implementation, an ADT is often packaged as an opaque data type or handle of some sort, in one or more modules , whose interface contains only the signature (number and types of the parameters and results) of the operations. The implementation of the module—namely, the bodies of the procedures and
3150-493: The implementation. An extension of ADT for computer graphics was proposed in 1979: an abstract graphical data type (AGDT). It was introduced by Nadia Magnenat Thalmann , and Daniel Thalmann . AGDTs provide the advantages of ADTs with facilities to build graphical objects in a structured way. Abstract data types are theoretical entities, used (among other things) to simplify the description of abstract algorithms, to classify and evaluate data structures, and to formally describe
3220-459: The interface, the constraints are still important to the definition of the ADT; for example a stack and a queue have similar add element/remove element interfaces, but it is the constraints that distinguish last-in-first-out from first-in-first-out behavior. The constraints do not consist only of equations such as fetch(store(S,v))=v but also logical formulas . In the spirit of functional programming , each state of an abstract data structure
3290-635: The list. After a few weeks of using the project internally with success, Sanfilippo decided to open source it, announcing the project on Hacker News . The project began to get traction, particularly among the Ruby community, with GitHub and Instagram being among the first companies adopting it. Sanfilippo was hired by VMware in March, 2010. In May, 2013, Redis was sponsored by Pivotal Software (a VMware spin-off). In June 2015, development became sponsored by Redis Labs . In August 2018, Redis Labs announced
3360-463: The location V . The constraints are described informally as that reads are consistent with writes. As in many programming languages, the operation store ( V , x ) is often written V ← x (or some similar notation), and fetch ( V ) is implied whenever a variable V is used in a context where a value is required. Thus, for example, V ← V + 1 is commonly understood to be a shorthand for store ( V , fetch ( V ) + 1). In this definition, it
3430-581: The module declares procedures that correspond to the ADT operations, often with comments that describe the constraints. This information hiding strategy allows the implementation of the module to be changed without disturbing the client programs, but the module only informally defines an ADT. The notion of abstract data types is related to the concept of data abstraction , important in object-oriented programming and design by contract methodologies for software engineering . ADTs were first proposed by Barbara Liskov and Stephen N. Zilles in 1974, as part of
3500-405: The most recent store operation on the same variable V , i.e. fetch(store(V,x)) = x . We may also require that store overwrites the value fully, store(store(V,x1),x2) = store(V,x2) . In the operational semantics, fetch ( V ) is a procedure that returns the current value in the location V , and store ( V , x ) is a procedure with void return type that stores the value x in
3570-405: The operations as if only one instance exists during the execution of the algorithm, and all operations are applied to that instance. For example, a stack may have operations push ( x ) and pop (), that operate on the only existing stack. ADT definitions in this style can be easily rewritten to admit multiple coexisting instances of the ADT, by adding an explicit instance parameter (like S in
SECTION 50
#17327937841773640-403: The order in which operations are evaluated is important, and the same operation on the same entities may have different effects if executed at different times. This is analogous to the instructions of a computer or the commands and procedures of an imperative language. To underscore this view, it is customary to say that the operations are executed or applied , rather than evaluated , similar to
3710-399: The representation and implemented procedures. For example, integers may be specified as an ADT, defined by the distinguished values 0 and 1, the operations of addition, subtraction, multiplication, division (with care for division by zero), comparison, etc., behaving according to the familiar mathematical axioms in abstract algebra such as associativity, commutativity, and so on. However, in
3780-578: The result of create () is distinct from any instance already in use by the algorithm. Implementations of ADTs may still reuse memory and allow implementations of create () to yield a previously created instance; however, defining that such an instance even is "reused" is difficult in the ADT formalism. More generally, this axiom may be strengthened to exclude also partial aliasing with other instances, so that composite ADTs (such as trees or records) and reference-style ADTs (such as pointers) may be assumed to be completely disjoint. For example, when extending
3850-409: The same functional behavior but with different complexity tradeoffs, the user of this code will be unpleasantly surprised. I could tell him anything I like about data abstraction, and he still would not want to use the code. Complexity assertions have to be part of the interface. Other authors disagree, arguing that a stack ADT is the same whether it is implemented with a linked list or an array, despite
3920-501: The same node, and commands related to database selection operations are unavailable. A Redis cluster can scale up to 1,000 nodes, achieve "acceptable" write safety and to continue operations when some nodes fail. Due to the nature of the database design, typical use cases are session caching, full page cache, message queue applications, leaderboards and counting among others. The publish–subscribe messaging paradigm allows real-time communication between servers. Amazon Web Services offers
3990-420: The same result for all of its members. Some common ADTs, which have proved useful in a great variety of applications, are Each of these ADTs may be defined in many ways and variants, not necessarily equivalent. For example, an abstract stack may or may not have a count operation that tells how many items have been pushed and not yet popped. This choice makes a difference not only for its clients but also for
4060-415: The same results (and output states). The constraints are specified as axioms or algebraic laws that the operations must satisfy. In the spirit of imperative programming , an abstract data structure is conceived as an entity that is mutable —meaning that there is a notion of time and the ADT may be in different states at different times. Operations then change the state of the ADT over time; therefore,
4130-718: The same time and each value takes the same space regardless of the state of the ADT, or that there is a "size" of the ADT and the operations are linear, quadratic, etc. in the size of the ADT. Alexander Stepanov , designer of the C++ Standard Template Library , included complexity guarantees in the STL specification, arguing: The reason for introducing the notion of abstract data types was to allow interchangeable software modules. You cannot have interchangeable modules unless these modules share similar complexity behavior. If I replace one module with another module with
4200-422: The stack example below) to every operation that uses or modifies the implicit instance. Some ADTs cannot be meaningfully defined without allowing multiple instances, for example when a single operation takes two distinct instances of the ADT as parameters, such as a union operation on sets or a compare operation on lists. The multiple instance style is sometimes combined with an aliasing axiom, namely that
4270-492: The stack state s continues to exist after a call x ← pop ( s ). In practice the formal definition should specify that the space is proportional to the number of items pushed and not yet popped; and that every one of the operations above must finish in a constant amount of time, independently of that number. To comply with these additional specifications, the implementation could use a linked list, or an array (with dynamic resizing) together with two integers (an item count and
SECTION 60
#17327937841774340-589: The stack, these could have the types p u s h : S → X → S {\displaystyle push:S\to X\to S} , p o p : S → ( S , X ) {\displaystyle pop:S\to (S,X)} , t o p : S → X {\displaystyle top:S\to X} , c r e a t e : S {\displaystyle create:S} , and e m p t y : S → B {\displaystyle empty:S\to \mathbb {B} } . In
4410-494: The state of any other ADT instance, including other stacks; that is: A more involved example is the Boom hierarchy of the binary tree , list , bag and set abstract data types. All these data types can be declared by three operations: null , which constructs the empty container, single , which constructs a container from a single element and append , which combines two containers of the same type. The complete specification for
4480-493: The stored value(s) for its instances, to members of a specific set X called the range of those variables. For example, an abstract variable may be constrained to only store integers. As in programming languages, such restrictions may simplify the description and analysis of algorithms , and improve its readability. In the operational style, it is often unclear how multiple instances are handled and if modifying one instance may affect others. A common style of defining ADTs writes
4550-553: The switch to a source-available software license, Server Side Public License for some of the optional modules available for Redis, while affirming that the core software will remain BSD-licensed. In October 2018, Redis 5.0 was released, introducing Redis Stream – a new data structure that allows storage of multiple fields and string values with an automatic, time-based sequence at a single key. In June 2020, Salvatore Sanfilippo stepped down as Redis' sole maintainer. Sanfilippo
4620-526: The system names, Google Trends , Stack Overflow discussions, job offers with mentions of the systems, number of profiles in professional networks such as LinkedIn , mentions in social networks such as Twitter . The ranking is updated monthly. It has been described and cited in various database-related articles. By grouping over specific database features like database model or type of license, regularly published statistics reveal historical trends which are used in strategic statements. In June 2024,
4690-410: The type of the abstract variable and X {\displaystyle X} be the type of its contents, fetch is a function V → X {\displaystyle V\to X} and store is a function of type V → X → V {\displaystyle V\to X\to V} . The main constraint is that fetch always returns the value x used in
4760-407: The value as the result but not the new state of the stack. There is then the constraint that, for any value x and any abstract variable V , the sequence of operations { push ( S , x ); V ← pop ( S ) } is equivalent to V ← x . Since the assignment V ← x , by definition, cannot change the state of S , this condition implies that V ← pop ( S ) restores S to the state it had before
4830-526: Was succeeded by Yossi Gottlieb and Oran Agra. In March 2024, Redis switched to a different proprietary software license, styled as the Redis Source Available License v2, and the Server Side Public License v1, also for its core repository, breaking the 2018 pledge. As a consequence, the Linux Foundation created a fork under the name of Valkey , allowing community maintainers, contributors, and users to continue working on an open source version of
4900-451: Was trying to improve the scalability of his Italian startup, developing a real-time web log analyzer. After encountering significant problems in scaling some types of workloads using traditional database systems, Sanfilippo began in 2009 to prototype a first proof of concept version of Redis in Tcl . Later Sanfilippo translated that prototype to the C language and implemented the first data type,
#176823