|
1 | | -# RediSQL |
| 1 | +# RediSQL: Fast, in memory, SQL. With Batteries included. |
| 2 | + |
| 3 | +RediSQL is the Fast, in-memory, SQL engine with batteries included. |
| 4 | + |
| 5 | +It provides several benefits for your application. |
| 6 | + |
| 7 | +1. Fast, it can top up to 130k inserts per *seconds*. |
| 8 | +2. Familiar, it works with standard SQL, no weird dialect or syntax to learn. |
| 9 | +3. Easy to Operate, it is based on Redis, just start the standard Redis binary and and pass the RediSQL binary. |
| 10 | +4. Easy to Use, being based on Redis there are already bindings for any language. |
| 11 | + |
| 12 | +## Use cases |
| 13 | + |
| 14 | +There are several use cases for RediSQL. |
| 15 | + |
| 16 | +### RediSQL to store Transient Data |
| 17 | + |
| 18 | +RediSQL is wonderful for transient data. |
| 19 | +With supports for lightweights DBs you can just store all the data that are important now, and trash them all together as soon as they are not necessary anymore. |
| 20 | + |
| 21 | +### RediSQL as main database |
| 22 | + |
| 23 | +The product is stable, it does not loose data and you can store the data into regular files to gain in persistency. |
| 24 | +Moreover RediSQL support all the persistency features of Redis, hence RDB and AOF are both fully supported. |
| 25 | + |
| 26 | +## Much more to explore... |
| 27 | + |
| 28 | +There are a lot of features in RediSQL that is worth to explore more, here a short excerpt of those features, please follow the link on the main website. |
| 29 | + |
| 30 | +#### Lightweight DBs |
| 31 | + |
| 32 | +RediSQL provides you with lightweight in memory databases. |
| 33 | +It could completely shift your architecture, indeed you could thing to create a new isolated database each day, or for every tenant of your application or even for each of your users. |
| 34 | + |
| 35 | +#### On disk storage |
| 36 | + |
| 37 | +While RediSQL focus on in-memory database, it can also store data in a regular file. Of course this makes operations slower, but it allow to reach a level of persistency and safeness of data on pair with regular databases as Postgres or MySQL. |
| 38 | + |
| 39 | +#### Copy of DBs |
| 40 | + |
| 41 | +With the concept of lightweight databases it become necessary to have a way to duplicate your database. |
| 42 | +Indeed it is possible to copy a database into another one. |
| 43 | +This allow several interesting patterns. |
| 44 | +For example you could copy an in-memory database into a file-backed database and then ship the file for storage or other analysis. |
| 45 | +Another pattern would be to copy a heavy read database into another for load balancing reasons. |
| 46 | +Moreover you may use the copy function to keep a "base-database" to grow when new data comes in. |
| 47 | + |
| 48 | +#### Directly expose the DB to users |
| 49 | + |
| 50 | +With the ability to create several lightweight databases and the capability to copy those database, you could directly expose directly the databases to the final users instead of exposing a set of API that you would need to maintain. |
| 51 | +Just load all the data that the user may need into a RediSQL database, document the tables that are available, and give access to it to the users. |
| 52 | +They will write their own API without waiting on you. |
| 53 | + |
| 54 | +#### Stream and cache query results |
| 55 | + |
| 56 | +RediSQL allow to store the results of queries into a Redis Stream. |
| 57 | +This allow different clients to consume part of the result, or to delay the consuption of a result. |
| 58 | +Moreover it allow to cache the result of expensive queries into Redis Streams and consume them over and over again. |
| 59 | + |
| 60 | +#### Complete JSON support |
| 61 | + |
| 62 | +JSON is the de-facto standard to share data between application, indeed RediSQL exploit the JSON1 module of SQLite to bring you the capability to easy and quickly manage JSON data inside SQL statements and tables. |
| 63 | +In RediSQL you are able to manipulate JSON in all the possible way. |
| 64 | + |
| 65 | +#### Full text search support |
| 66 | + |
| 67 | +RediSQL fully supports also the FTS{3,4,5} engine in SQLite giving you a full text engine at your fingertip. |
| 68 | +You will be able to manage and search for data. |
| 69 | + |
| 70 | +## Getting started |
| 71 | + |
| 72 | +RediSQL is a Redis module, hence you will need a modern version of [Redis (> 5.0)][redis-download] and the RediSQL .so file. |
| 73 | + |
| 74 | +You can obtain RediSQL directly [from our store.](https://payhip.com/RediSQL) |
| 75 | + |
| 76 | +Alternative you can download the module from [github release.](https://github.com/RedBeardLab/rediSQL/releases) |
| 77 | + |
| 78 | +Finally you could compile the source yourself, simpy with `cargo build --release` from the root of the project. |
| 79 | + |
| 80 | +To start RediSQL you simply pass it as paramenter to the redis binary. |
| 81 | + |
| 82 | +``` |
| 83 | +./redis-server --loadmodule /path/to/RediSQL.so |
| 84 | +``` |
| 85 | + |
| 86 | +At this point you have your standard redis instance working as you would expect plus all the RediSQL interface. |
| 87 | + |
| 88 | +All the commands are documented in [the references.][api] |
| 89 | + |
| 90 | +## Tutorials and walkthrought |
| 91 | + |
| 92 | +We create a few tutorial to guide you on using RediSQL with Node.js, Go(lang) and Python: |
| 93 | + |
| 94 | +- [Using RediSQL with Python](http://redbeardlab.tech/rediSQL/blog/python/using-redisql-with-python/) |
| 95 | +- [Using RediSQL with Golang](http://redbeardlab.tech/rediSQL/blog/golang/using-redisql-with-golang/) |
| 96 | +- [Using RediSQL with Node.js](http://redbeardlab.tech/rediSQL/blog/node/using-redisql-with-node/) |
| 97 | + |
| 98 | +Please open an issue and request a tutorial for any other language you are intereted in. |
| 99 | + |
| 100 | +The fastest way to explore RediSQL is using the `redis-cli`. |
| 101 | + |
| 102 | +``` |
| 103 | +$ ~/redis-4.0-rc1/src/redis-cli |
| 104 | +127.0.0.1:6379> |
| 105 | +127.0.0.1:6379> SET A 3 |
| 106 | +OK |
| 107 | +127.0.0.1:6379> GET A |
| 108 | +"3" |
| 109 | +# Great, still the old good redis we know, but now with extra commands. |
| 110 | +127.0.0.1:6379> REDISQL.CREATE_DB DB |
| 111 | +OK |
| 112 | +# Start creating a table on the default DB |
| 113 | +127.0.0.1:6379> REDISQL.EXEC DB "CREATE TABLE foo(A INT, B TEXT);" |
| 114 | +DONE |
| 115 | +# Insert some data into the table |
| 116 | +127.0.0.1:6379> REDISQL.EXEC DB "INSERT INTO foo VALUES(3, 'bar');" |
| 117 | +OK |
| 118 | +# Retrieve the data you just inserted |
| 119 | +127.0.0.1:6379> REDISQL.EXEC DB "SELECT * FROM foo;" |
| 120 | +1) 1) (integer) 3 |
| 121 | + 2) "bar" |
| 122 | +# Of course you can make multiple tables |
| 123 | +127.0.0.1:6379> REDISQL.EXEC DB "CREATE TABLE baz(C INT, B TEXT);" |
| 124 | +OK |
| 125 | +127.0.0.1:6379> REDISQL.EXEC DB "INSERT INTO baz VALUES(3, 'aaa');" |
| 126 | +OK |
| 127 | +127.0.0.1:6379> REDISQL.EXEC DB "INSERT INTO baz VALUES(3, 'bbb');" |
| 128 | +OK |
| 129 | +127.0.0.1:6379> REDISQL.EXEC DB "INSERT INTO baz VALUES(3, 'ccc');" |
| 130 | +OK |
| 131 | +# And of course you can use joins |
| 132 | +127.0.0.1:6379> REDISQL.EXEC DB "SELECT * FROM foo, baz WHERE foo.A = baz.C;" |
| 133 | +
|
| 134 | +1) 1) (integer) 3 |
| 135 | + 2) "bar" |
| 136 | + 3) (integer) 3 |
| 137 | + 4) "aaa" |
| 138 | +2) 1) (integer) 3 |
| 139 | + 2) "bar" |
| 140 | + 3) (integer) 3 |
| 141 | + 4) "bbb" |
| 142 | +3) 1) (integer) 3 |
| 143 | + 2) "bar" |
| 144 | + 3) (integer) 3 |
| 145 | + 4) "ccc" |
| 146 | +127.0.0.1:6379> |
| 147 | +``` |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | + |
| 153 | +## OLD |
2 | 154 |
|
3 | 155 | RediSQL is a module for Redis that embed a completely functional SQLite database. |
4 | 156 |
|
|
0 commit comments