From 59da3844a9d9c0b8bac6a89eebe9866d38351bea Mon Sep 17 00:00:00 2001 From: PrasanKumar Date: Tue, 8 Nov 2022 18:47:44 +0530 Subject: [PATCH 01/16] new getting started page --- docs/create/linux/index-linux.mdx | 44 + .../quick-start/index-quick-start-old.mdx | 826 ++++++++++++++++++ docs/howtos/quick-start/index-quick-start.mdx | 757 ++++++++++++++++ docusaurus.config.js | 25 +- sidebars.js | 2 + static/img/profile_pic_prasan_kumar.jpg | Bin 0 -> 14056 bytes 6 files changed, 1645 insertions(+), 9 deletions(-) create mode 100644 docs/create/linux/index-linux.mdx create mode 100644 docs/howtos/quick-start/index-quick-start-old.mdx create mode 100644 docs/howtos/quick-start/index-quick-start.mdx create mode 100644 static/img/profile_pic_prasan_kumar.jpg diff --git a/docs/create/linux/index-linux.mdx b/docs/create/linux/index-linux.mdx new file mode 100644 index 00000000000..f365b918b26 --- /dev/null +++ b/docs/create/linux/index-linux.mdx @@ -0,0 +1,44 @@ +--- +id: index-linux +title: Create a Redis database on Linux +description: A step by step guide to create a Redis database on Linux. +sidebar_label: Redis on Linux +slug: /create/linux/ +authors: [prasan] +--- + +import Authors from '@site/src/theme/Authors'; + + + +### From the official Debian/Ubuntu APT Repository + +You can install recent stable versions of Redis Stack from the official packages.redis.io APT repository. The repository currently supports Debian Bullseye (11), Ubuntu Xenial (16.04), Ubuntu Bionic (18.04), and Ubuntu Focal (20.04) on x86 processors. Add the repository to the apt index, update it, and install it: + +```sh +curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list +sudo apt-get update +sudo apt-get install redis-stack-server +``` + +### From the official RPM Feed + +You can install recent stable versions of Redis Stack from the official packages.redis.io YUM repository. The repository currently supports RHEL7/CentOS7, and RHEL8/Centos8. Add the repository to the repository index, and install the package. + +Create the file /etc/yum.repos.d/redis.repo with the following contents + +``` +[Redis] +name=Redis +baseurl=http://packages.redis.io/rpm/rhel7 +enabled=1 +gpgcheck=1 +``` + +```sh +curl -fsSL https://packages.redis.io/gpg > /tmp/redis.key +sudo rpm --import /tmp/redis.key +sudo yum install epel-release +sudo yum install redis-stack-server +``` diff --git a/docs/howtos/quick-start/index-quick-start-old.mdx b/docs/howtos/quick-start/index-quick-start-old.mdx new file mode 100644 index 00000000000..ed46e90d6d4 --- /dev/null +++ b/docs/howtos/quick-start/index-quick-start-old.mdx @@ -0,0 +1,826 @@ +--- +id: index-quick-start-old +title: Quick Start +sidebar_label: Quick Start Old +slug: /howtos/quick-start-old +authors: [prasan] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import useBaseUrl from '@docusaurus/useBaseUrl'; + +
+ +## Setup Redis + +Use one of the following ways to set up Redis : + +- **Cloud** : Hosted and serverless database-as-a-service (DBaaS). The fastest way to deploy Redis Enterprise via Amazon AWS, Google Cloud Platform or Microsoft Azure. + - [Getting Started](/create/rediscloud), [Videos](https://www.youtube.com/playlist?list=PL83Wfqi-zYZG6uGxBagsbqjpsi2XBEj1K), + [Free Signup](https://app.redislabs.com/#/login) +- **Manual Software** : A self-managed data platform that unlocks the full potential of Redis at enterprise scale on various operating systems like Mac OS, Windows or Linux. + + + + + +```sh +# install redis-stack +brew tap redis-stack/redis-stack +brew install --cask redis-stack + +# start redis-stack +redis-stack-server +``` + +Detailed MacOS instructions can be viewed [here](/create/homebrew/) + + + + + +- **Ubuntu** (16.04, 18.04, 20.04) + +```sh +curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list +sudo apt-get update +sudo apt-get install redis-stack-server +``` + +- **RHEL/ CentOS** (7, 8) + +Create the file /etc/yum.repos.d/redis.repo with the following contents + +``` +[Redis] +name=Redis +baseurl=http://packages.redis.io/rpm/rhel7 +enabled=1 +gpgcheck=1 +``` + +```sh +curl -fsSL https://packages.redis.io/gpg > /tmp/redis.key +sudo rpm --import /tmp/redis.key +sudo yum install epel-release +sudo yum install redis-stack-server +``` + +Detailed Linux instructions can be viewed [here](https://redis.io/docs/stack/get-started/install/linux/) + + + + +Below docker run command exposes RedisServer on 6379 and RedisInsight on port 8001. +You can use RedisInsight by pointing your browser to localhost:8001. + +```sh +# install +docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest +``` + +You can use redis-cli to connect to the server. +If you don’t have redis-cli installed locally, you can run it from the Docker container like below: + +```sh +# connect +docker exec -it redis-stack redis-cli +``` + +Detailed Docker instructions can be viewed [here](/create/docker/redis-on-docker) + + + + + +**(TODO : - No redis stack example)** + +Redis is not officially supported on Windows, but can be installed via WSL2 (Windows Subsystem for Linux) for development purpose + +- Enable [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install) to run Ubuntu on Windows and follow below Ubuntu steps + +```sh +curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg + +echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list + +sudo apt-get update +sudo apt-get install redis +``` + +``` +# start the Redis server +sudo service redis-server start + +# Connect to Redis +redis-cli +``` + +Detailed Windows instructions can be viewed [here](/create/windows) **TODO : outdated respective to io site?** + + + + + +## Basic Querying + + + + + +- We can connect to Redis using CLI or **[Redis Insights](https://redis.io/docs/stack/insight/)** (a GUI tool to visualize data & run commands) + +```sh +# syntax 1 : connect using host & port +redis-cli -h host -p port -a password + +# example 1 +redis-cli -h redis15.localnet.org -p 6390 -a myUnguessablePassword + +# syntax 2 : connect using uri +redis-cli -u redis://user:password@host:port/dbnum + +# example 2 +redis-cli -u redis://LJenkins:p%40ssw0rd@redis-16379.hosted.com:16379/0 + +``` + +- Basic CLI / RedisInsights workbench commands + +```sh +# syntax : Check specific keys +keys pattern + +# example +keys * + +#------------ +# syntax : Check number of keys in database +dbsize + +#------------ +# syntax : set a key value +set key value EX expirySeconds + +# example +set company redis EX 60 + +#------------ +# syntax : get value by key +get key + +# example +get company + +#------------ +# syntax : delete keys +del key1 key2 key3 ... keyN + +# example +del company + +#------------ +# syntax : Check if key exists +exists key1 + +# example +exists company + +#------------ +# syntax : set expiry to key +expire key seconds + +# example +expire lastname 60 + +#------------ +# syntax : remove expiry from key +persist key + +# example +persist lastname + +#------------ +# syntax : find (remaining) time to live of a key +ttl key + +# example +ttl lastname + +#------------ +# syntax : increment a number +incr key + +# example +incr counter + +#------------ +# syntax : decrement a number +decr key + +# example +decr counter +``` + +Detailed CLI instructions can be viewed [here](https://redis.io/docs/manual/cli/) and +commands can be checked [here](https://redis.io/commands/) + + + + + +```sh +# install redis in the project +npm install redis --save +``` + +```js +//create client & connect to redis + +import { createClient } from 'redis'; + +const client = createClient({ + //redis[s]://[[username][:password]@][host][:port][/db-number] + url: 'redis://alice:foobared@awesome.redis.server:6380', +}); + +client.on('error', (err) => console.log('Redis Client Error', err)); + +await client.connect(); +``` + +```js +// Check specific keys +const pattern = '*'; +await client.keys(pattern); + +#------------ +// Check number of keys in database +await client.dbsize(); + +#------------ +// set key value +await client.set('key', 'value'); +await client.set('key', 'value', { + EX: 10, + NX: true, +}); + +#------------ +// get value by key +const value = await client.get('key'); + +#------------ +//syntax : delete keys +await client.del('key'); +const keyArr = ['key1', 'key2', 'key3']; +await client.del(...keyArr); + +#------------ +// Check if key exists +await client.exists('key'); + +#------------ +// set expiry to key +const expireInSeconds = 30; +await client.expire('key', expireInSeconds); + +#------------ +// remove expiry from key +await client.persist('key'); + +#------------ +// find (remaining) time to live of a key +await client.ttl('key'); + +#------------ +// increment a number +await client.incr('key'); + +#------------ +// decrement a number +await client.decr('key'); + +#------------ +//use below style for unsupported commands by client library +await client.sendCommand(['SET', 'key', 'value']); +``` + +```js +//graceful disconnecting +await client.quit(); + +//forceful disconnecting +await client.disconnect(); +``` + +- More details at [Github repo](https://github.com/redis/node-redis) and also check Javascript/ NodeJS apps at [Redis Launchpad](https://launchpad.redis.com/) + + + +- TODO: similar commands to be written + + + + +- TODO: similar commands to be written + + + + +- TODO: similar commands to be written + + + + +## Redis Modules + + + + + +RedisJSON module adds JSON data type for Redis. + +- Example : Object type + +```sh +# syntax : set an object value to a key +JSON.SET objKey $ value + +# example +JSON.SET person $ '{"name":"Leonard Cohen","dob":1478476800,"isActive": true, "hobbies":["music", "cricket"]}' + +#------------ +# syntax : get object value of a key +JSON.GET objKey $ + +# example +JSON.GET person $ + +#------------ +# syntax : find object key length +JSON.OBJLEN objKey $ + +# example +JSON.OBJLEN person $ + +#------------ +# syntax : find object keys +JSON.OBJKEYS objKey $ + +# example +JSON.OBJKEYS person $ + +#------------ +# syntax : update nested property +JSON.SET objKey $.prop value + +# example +JSON.SET person $.name '"Alex"' + +#------------ +# syntax : update nested array +JSON.SET objKey $.arrayProp fullValue +JSON.SET objKey $.arrayProp[index] value + +# example +JSON.SET person $.hobbies '["music", "cricket"]' +JSON.SET person $.hobbies[1] '"dance"' + +#------------ +# syntax : remove nested array item by index +JSON.ARRPOP objKey $.arrayProp index + +# example +JSON.ARRPOP person $.hobbies 1 +``` + +- Example : String type + +```sh +# syntax : set & get +JSON.SET key path value +JSON.GET key path + +# example +JSON.SET foo $ '"bar"' +JSON.GET foo $ + +#------------ +# syntax : string append +JSON.STRAPPEND key path value + +# example +JSON.STRAPPEND foo $ '"baz"' + +#------------ +# syntax : string length +JSON.STRLEN key path + +# example +JSON.STRLEN foo $ +``` + +- Example : Number type + +```sh +# syntax : set & get +JSON.SET key path value +JSON.GET key path + +# example +JSON.SET num $ 0 +JSON.GET num $ + +#------------ +# syntax : number increment by +JSON.NUMINCRBY key path value + +# example +JSON.NUMINCRBY num $ 1 +JSON.NUMINCRBY num $ 1.5 +JSON.NUMINCRBY num $ -0.75 +``` + +- Example : Array type + +```sh +# syntax : set & get +JSON.SET key path value +JSON.GET key path + +# example +JSON.SET myArray $ '[ true, { "answer": 42 }, null ]' +JSON.GET myArray $ + +#------------ +# syntax : get array item by index +JSON.GET key $[index]] + +# example +JSON.GET myArray $[1] +JSON.GET myArray $[1].answer + +#------------ +# syntax : delete array item by index +JSON.DEL key path +JSON.ARRPOP key path index + +# example +JSON.DEL myArray $[0] +JSON.ARRPOP myArray $ 0 + +#------------ +# syntax : append items to array +JSON.ARRAPPEND key path value1 value2 valueN + +# example +JSON.ARRAPPEND myArray $ '"A"' + +#------------ +# syntax : insert items to array at index +JSON.ARRINSERT key path index value1 value2 valueN + +# example +JSON.ARRINSERT myArray $ 0 '"C"' '"D"' + +#------------ +# syntax : Trims an array to specific inclusive range. +JSON.ARRTRIM key path start stop + +# example +JSON.ARRTRIM myArray $ 0 2 +``` + +More RedisJSON details can be found in [docs](https://redis.io/docs/stack/json/) + + + + Redis Search is a query and indexing engine for Redis, providing secondary indexing, full-text search and aggregations capabilities. + +- We have to create index on schema to be able to search on its data + +```sh +# syntax +FT.CREATE {index_name} ON JSON SCHEMA {json_path} AS {attribute} {type} +# note : attribute = logical name, json_path = JSONPath expressions + +# example +FT.CREATE userIdx ON JSON SCHEMA $.user.name AS name TEXT $.user.hobbies AS hobbies TAG $.user.age as age NUMERIC +# note : Can search by any attribute mentioned in the above index. +``` + +- More details on Indexing JSON can be found [here](https://redis.io/docs/stack/search/indexing_json/) + +Once index is created, any pre-existing/ new/ modified JSON document is automatically indexed. + +```json +//sample json document +{ + "user": { + "name": "John Smith", + "hobbies": "foo,bar", + "age": 23 + } +} +``` + +```sh +# adding JSON document +JSON.SET myDoc $ '{"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}' +``` + +- Search + +```sh +# search all user documents with name 'John' +FT.SEARCH userIdx '@name:(John)' + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$" + 2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}" +``` + +- Search & project required fields + +```sh +# search documents with name 'John' & project only age field +FT.SEARCH userIdx '@name:(John)' RETURN 1 $.user.age + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$.user.age" + 2) "23" +``` + +```sh +# project multiple fields +FT.SEARCH userIdx '@name:(John)' RETURN 2 $.user.age $.user.name + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$.user.age" + 2) "23" + 3) "$.user.name" + 4) "John Smith" + +#------------ +# project with alias name +FT.SEARCH userIdx '@name:(John)' RETURN 3 $.user.age AS userAge + +1) (integer) 1 +2) "myDoc" +3) 1) "userAge" + 2) "23" +#------------ + +# multi field query +FT.SEARCH userIdx '@name:(John) @hobbies:{foo | me} @age:[20 30]' + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$" + 2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}" +``` + +More details on [query syntax](https://redis.io/docs/stack/search/reference/query_syntax/) + +- Drop index + +```sh +FT.DROPINDEX userIdx +``` + +Watch video [RediSearch (RedisConf 2020)](https://www.youtube.com/watch?v=9R29LLWquME), also more details can be found in [docs](https://redis.io/docs/stack/search/) + + + + +A graph database as a Redis module + +TODO : to be read & written + + + + +Time Series data structure for Redis + +TODO : to be read & written + + + + + +Dynamic execution framework for your Redis data + +TODO : to be written + + + + + +Probabilistic Datatypes Module for Redis + +TODO : to be read & written + + + + + +## Redis OM + +Redis OM is a client library to work with Redis **easily**. +It allows you to model redis data , save & search json data ..etc + + + + + +```sh +# install RedisOM in the project +npm install redis-om --save +``` + +- create RedisOM Client & connect to redis + +```js +//client.js file + +import { Client } from 'redis-om'; + +// pulls the Redis URL from .env +const url = process.env.REDIS_URL; + +const client = new Client(); +await client.open(url); + +export default client; +``` + +- Create Entity, Schema & Repository + +```js +//person.js file + +import { Entity, Schema } from 'redis-om'; +import client from './client.js'; + +class Person extends Entity {} + +const personSchema = new Schema(Person, { + firstName: { type: 'string' }, + lastName: { type: 'string' }, + age: { type: 'number' }, + verified: { type: 'boolean' }, + location: { type: 'point' }, + locationUpdated: { type: 'date' }, + skills: { type: 'string[]' }, + personalStatement: { type: 'text' }, +}); + +export const personRepository = client.fetchRepository(personSchema); + +//creating index to make person schema searchable +await personRepository.createIndex(); +``` + +```js +import { Router } from 'express'; +import { personRepository } from 'person.js'; +``` + +- Insert sample + +```js +let input = { + firstName: 'Rupert', + lastName: 'Holmes', + age: 75, + verified: false, + location: { + longitude: 45.678, + latitude: 45.678, + }, + locationUpdated: '2022-03-01T12:34:56.123Z', + skills: ['singing', 'songwriting', 'playwriting'], + personalStatement: 'I like piña coladas and walks in the rain', +}; +const person = await personRepository.createAndSave(input); +``` + +- Read sample + +```js +const id = '01FX8N39YVZRCQNAW0R5T53H5T'; +const person = await personRepository.fetch(id); +``` + +- Update sample + +```js +const person = await personRepository.fetch(req.params.id); + +person.firstName = 'Alex'; + +//null to remove that field +person.lastName = null; + +await personRepository.save(person); +``` + +- Update location sample + +```js +const id = '01G79HZ6P3WYWFTY36JF6H3529'; +const longitude = Number('45.678'); +const latitude = 45.678; +const locationUpdated = new Date(); + +const person = await personRepository.fetch(id); +person.location = { longitude, latitude }; +person.locationUpdated = locationUpdated; +await personRepository.save(person); +``` + +- Delete sample + +```js +await personRepository.remove(req.params.id); +``` + +- Search samples + +```js +//get all records of persons +const queryBuilder = personRepository.search(); +const persons = await queryBuilder.return.all(); + +//"multiple and" condition sample +const queryBuilder = personRepository + .search() + .where('verified') + .eq(true) // == + .and('age') + .gte(21) // >= + .and('lastName') + .eq(lastName); +//console.log(queryBuilder.query); +const persons = await queryBuilder.return.all(); + +// "OR" condition sample +const queryBuilder = personRepository + .search() + .where('verified') + .eq(true) + .or((search) => search.where('age').gte(21).and('lastName').eq(lastName)) + .sortAscending('age'); +const persons = await queryBuilder.return.all(); +``` + +Useful links : [Github repo](https://github.com/redis/redis-om-node) and [getting started docs](https://redis.io/docs/stack/get-started/tutorials/stack-node/), +[getting started video](https://www.youtube.com/watch?v=KUfufrwpBkM) and it's [source code](https://github.com/redis-developer/express-redis-om-workshop) + + + + +- Join the [community](/community/) + +
diff --git a/docs/howtos/quick-start/index-quick-start.mdx b/docs/howtos/quick-start/index-quick-start.mdx new file mode 100644 index 00000000000..aa875bd080d --- /dev/null +++ b/docs/howtos/quick-start/index-quick-start.mdx @@ -0,0 +1,757 @@ +--- +id: index-quick-start +title: Quick Start +sidebar_label: Quick Start +slug: /howtos/quick-start +authors: [prasan] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import useBaseUrl from '@docusaurus/useBaseUrl'; +import Authors from '@site/src/theme/Authors'; + + + +
+ +## Setup Redis + +Use one of the following ways to set up Redis : + +- **Cloud** : Hosted and serverless database-as-a-service (DBaaS). The fastest way to deploy Redis Enterprise via Amazon AWS, Google Cloud Platform or Microsoft Azure. + - [Getting Started](/create/rediscloud), [Videos](https://www.youtube.com/playlist?list=PL83Wfqi-zYZG6uGxBagsbqjpsi2XBEj1K), + [Free Signup](https://app.redislabs.com/#/login) +- **OnPrem/ Desktop** : A self-managed data platform that unlocks the full potential of Redis at enterprise scale on various operating systems like Mac OS, Windows or Linux. + + + + + +```sh +# install redis-stack +brew tap redis-stack/redis-stack +brew install --cask redis-stack + +# start redis-stack +redis-stack-server +``` + +Detailed MacOS instructions can be viewed [here](/create/homebrew/) + + + + + +- **Ubuntu** (16.04, 18.04, 20.04) + +```sh +curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list +sudo apt-get update +sudo apt-get install redis-stack-server +``` + +- **RHEL/ CentOS** (7, 8) + +Create the file /etc/yum.repos.d/redis.repo with the following contents + +``` +[Redis] +name=Redis +baseurl=http://packages.redis.io/rpm/rhel7 +enabled=1 +gpgcheck=1 +``` + +```sh +curl -fsSL https://packages.redis.io/gpg > /tmp/redis.key +sudo rpm --import /tmp/redis.key +sudo yum install epel-release +sudo yum install redis-stack-server +``` + +Detailed Linux instructions can be viewed [here](/create/linux/) + + + + +Below docker run command exposes RedisServer on 6379 and RedisInsight on port 8001. +You can use RedisInsight by pointing your browser to localhost:8001. + +```sh +# install +docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest +``` + +You can use redis-cli to connect to the server. +If you don’t have redis-cli installed locally, you can run it from the Docker container like below: + +```sh +# connect +docker exec -it redis-stack redis-cli +``` + +Detailed Docker instructions can be viewed [here](/create/docker/redis-on-docker) + + + + + +Redis is not officially supported on Windows, but can be installed via WSL2 (Windows Subsystem for Linux) for development purpose + +- Enable [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install) to run Ubuntu on Windows and follow below Ubuntu steps + +```sh + sudo apt-add-repository ppa:redislabs/redis + sudo apt-get update + sudo apt-get upgrade + sudo apt-get install redis-server +``` + +``` +# Restart the Redis server +sudo service redis-server restart + +# Connect to Redis +redis-cli +``` + +Detailed Windows instructions can be viewed [here](/create/windows) + + + + + +## Basic Querying + + + + + +- We can connect to Redis using CLI or **[Redis Insights](https://redis.io/docs/stack/insight/)** (a GUI tool to visualize data & run commands) + +```sh +# syntax 1 : connect using host & port +redis-cli -h host -p port -a password + +# example 1 +redis-cli -h redis15.localnet.org -p 6390 -a myUnguessablePassword + +# syntax 2 : connect using uri +redis-cli -u redis://user:password@host:port/dbnum + +# example 2 +redis-cli -u redis://LJenkins:p%40ssw0rd@redis-16379.hosted.com:16379/0 + +``` + +- Basic CLI / RedisInsights workbench commands + +```sh +# syntax : Check specific keys +keys pattern + +# example +keys * + +#------------ +# syntax : Check number of keys in database +dbsize + +#------------ +# syntax : set a key value +set key value EX expirySeconds + +# example +set company redis EX 60 + +#------------ +# syntax : get value by key +get key + +# example +get company + +#------------ +# syntax : delete keys +del key1 key2 key3 ... keyN + +# example +del company + +#------------ +# syntax : Check if key exists +exists key1 + +# example +exists company + +#------------ +# syntax : set expiry to key +expire key seconds + +# example +expire lastname 60 + +#------------ +# syntax : remove expiry from key +persist key + +# example +persist lastname + +#------------ +# syntax : find (remaining) time to live of a key +ttl key + +# example +ttl lastname + +#------------ +# syntax : increment a number +incr key + +# example +incr counter + +#------------ +# syntax : decrement a number +decr key + +# example +decr counter +``` + +Detailed CLI instructions can be viewed [here](https://redis.io/docs/manual/cli/) and +commands can be checked [here](https://redis.io/commands/) + + + + + +```sh +# install redis in the project +npm install redis --save +``` + +```js +//create client & connect to redis + +import { createClient } from 'redis'; + +const client = createClient({ + //redis[s]://[[username][:password]@][host][:port][/db-number] + url: 'redis://alice:foobared@awesome.redis.server:6380', +}); + +client.on('error', (err) => console.log('Redis Client Error', err)); + +await client.connect(); +``` + +```js +// Check specific keys +const pattern = '*'; +await client.keys(pattern); + +#------------ +// Check number of keys in database +await client.dbsize(); + +#------------ +// set key value +await client.set('key', 'value'); +await client.set('key', 'value', { + EX: 10, + NX: true, +}); + +#------------ +// get value by key +const value = await client.get('key'); + +#------------ +//syntax : delete keys +await client.del('key'); +const keyArr = ['key1', 'key2', 'key3']; +await client.del(...keyArr); + +#------------ +// Check if key exists +await client.exists('key'); + +#------------ +// set expiry to key +const expireInSeconds = 30; +await client.expire('key', expireInSeconds); + +#------------ +// remove expiry from key +await client.persist('key'); + +#------------ +// find (remaining) time to live of a key +await client.ttl('key'); + +#------------ +// increment a number +await client.incr('key'); + +#------------ +// decrement a number +await client.decr('key'); + +#------------ +//use below style for unsupported commands by client library +await client.sendCommand(['SET', 'key', 'value']); +``` + +```js +//graceful disconnecting +await client.quit(); + +//forceful disconnecting +await client.disconnect(); +``` + +- More details at [Github repo](https://github.com/redis/node-redis) and also check Javascript/ NodeJS apps at [Redis Launchpad](https://launchpad.redis.com/) + + + +- TODO: similar commands to be written + + + + +- TODO: similar commands to be written + + + + +- TODO: similar commands to be written + + + + +## Secondary indexing & searching JSON + + + + + +**RedisJSON** adds JSON data type for Redis. + +```sh +# syntax : set an object value to a key +JSON.SET objKey $ value + +# example +JSON.SET person $ '{"name":"Leonard Cohen","dob":1478476800,"isActive": true, "hobbies":["music", "cricket"]}' + +#------------ +# syntax : get object value of a key +JSON.GET objKey $ + +# example +JSON.GET person $ + +#------------ +# syntax : find object key length +JSON.OBJLEN objKey $ + +# example +JSON.OBJLEN person $ + +#------------ +# syntax : find object keys +JSON.OBJKEYS objKey $ + +# example +JSON.OBJKEYS person $ + +#------------ +# syntax : update nested property +JSON.SET objKey $.prop value + +# example +JSON.SET person $.name '"Alex"' + +#------------ +# syntax : update nested array +JSON.SET objKey $.arrayProp fullValue +JSON.SET objKey $.arrayProp[index] value + +# example +JSON.SET person $.hobbies '["music", "cricket"]' +JSON.SET person $.hobbies[1] '"dance"' + +#------------ +# syntax : remove nested array item by index +JSON.ARRPOP objKey $.arrayProp index + +# example +JSON.ARRPOP person $.hobbies 1 +``` + +More RedisJSON details can be found in [docs](https://redis.io/docs/stack/json/) + +--- + +**Redis Search** is a query and indexing engine for Redis, providing secondary indexing, full-text search and aggregations capabilities. + +- We have to create index on schema to be able to search on its data + +```sh +# syntax +FT.CREATE {index_name} ON JSON SCHEMA {json_path} AS {attribute} {type} +# note : attribute = logical name, json_path = JSONPath expressions + +# example +FT.CREATE userIdx ON JSON SCHEMA $.user.name AS name TEXT $.user.hobbies AS hobbies TAG $.user.age as age NUMERIC +# note : Can search by any attribute mentioned in the above index. +``` + +- More details on Indexing JSON can be found [here](https://redis.io/docs/stack/search/indexing_json/) + +Once index is created, any pre-existing/ new/ modified JSON document is automatically indexed. + +```json +//sample json document +{ + "user": { + "name": "John Smith", + "hobbies": "foo,bar", + "age": 23 + } +} +``` + +```sh +# adding JSON document +JSON.SET myDoc $ '{"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}' +``` + +- Search + +```sh +# search all user documents with name 'John' +FT.SEARCH userIdx '@name:(John)' + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$" + 2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}" +``` + +- Search & project required fields + +```sh +# search documents with name 'John' & project only age field +FT.SEARCH userIdx '@name:(John)' RETURN 1 $.user.age + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$.user.age" + 2) "23" +``` + +```sh +# project multiple fields +FT.SEARCH userIdx '@name:(John)' RETURN 2 $.user.age $.user.name + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$.user.age" + 2) "23" + 3) "$.user.name" + 4) "John Smith" + +#------------ +# project with alias name +FT.SEARCH userIdx '@name:(John)' RETURN 3 $.user.age AS userAge + +1) (integer) 1 +2) "myDoc" +3) 1) "userAge" + 2) "23" +#------------ + +# multi field query +FT.SEARCH userIdx '@name:(John) @hobbies:{foo | me} @age:[20 30]' + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$" + 2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}" +``` + +More details on [query syntax](https://redis.io/docs/stack/search/reference/query_syntax/) + +- Drop index + +```sh +FT.DROPINDEX userIdx +``` + +Watch video [RediSearch (RedisConf 2020)](https://www.youtube.com/watch?v=9R29LLWquME), also more details can be found in [docs](https://redis.io/docs/stack/search/) + + + + + +```sh +# install RedisOM in the project +npm install redis-om --save +``` + +- create RedisOM Client & connect to redis + +```js +//client.js file + +import { Client } from 'redis-om'; + +// pulls the Redis URL from .env +const url = process.env.REDIS_URL; + +const client = new Client(); +await client.open(url); + +export default client; +``` + +- Create Entity, Schema & Repository + +```js +//person.js file + +import { Entity, Schema } from 'redis-om'; +import client from './client.js'; + +class Person extends Entity {} + +const personSchema = new Schema(Person, { + firstName: { type: 'string' }, + lastName: { type: 'string' }, + age: { type: 'number' }, + verified: { type: 'boolean' }, + location: { type: 'point' }, + locationUpdated: { type: 'date' }, + skills: { type: 'string[]' }, + personalStatement: { type: 'text' }, +}); + +export const personRepository = client.fetchRepository(personSchema); + +//creating index to make person schema searchable +await personRepository.createIndex(); +``` + +```js +import { Router } from 'express'; +import { personRepository } from 'person.js'; +``` + +- Insert sample + +```js +let input = { + firstName: 'Rupert', + lastName: 'Holmes', + age: 75, + verified: false, + location: { + longitude: 45.678, + latitude: 45.678, + }, + locationUpdated: '2022-03-01T12:34:56.123Z', + skills: ['singing', 'songwriting', 'playwriting'], + personalStatement: 'I like piña coladas and walks in the rain', +}; +const person = await personRepository.createAndSave(input); +``` + +- Read sample + +```js +const id = '01FX8N39YVZRCQNAW0R5T53H5T'; +const person = await personRepository.fetch(id); +``` + +- Update sample + +```js +const person = await personRepository.fetch(req.params.id); + +person.firstName = 'Alex'; + +//null to remove that field +person.lastName = null; + +await personRepository.save(person); +``` + +- Update location sample + +```js +const id = '01G79HZ6P3WYWFTY36JF6H3529'; +const longitude = Number('45.678'); +const latitude = 45.678; +const locationUpdated = new Date(); + +const person = await personRepository.fetch(id); +person.location = { longitude, latitude }; +person.locationUpdated = locationUpdated; +await personRepository.save(person); +``` + +- Delete sample + +```js +await personRepository.remove(req.params.id); +``` + +- Search samples + +```js +//get all records of persons +const queryBuilder = personRepository.search(); +const persons = await queryBuilder.return.all(); + +//"multiple and" condition sample +const queryBuilder = personRepository + .search() + .where('verified') + .eq(true) // == + .and('age') + .gte(21) // >= + .and('lastName') + .eq(lastName); +//console.log(queryBuilder.query); +const persons = await queryBuilder.return.all(); + +// "OR" condition sample +const queryBuilder = personRepository + .search() + .where('verified') + .eq(true) + .or((search) => search.where('age').gte(21).and('lastName').eq(lastName)) + .sortAscending('age'); +const persons = await queryBuilder.return.all(); +``` + +Useful links : [Github repo](https://github.com/redis/redis-om-node) and [getting started docs](https://redis.io/docs/stack/get-started/tutorials/stack-node/), +[getting started video](https://www.youtube.com/watch?v=KUfufrwpBkM) and it's [source code](https://github.com/redis-developer/express-redis-om-workshop) + + + + + + + + + + + + + + + + +## Sync with other databases + +RedisGears adds dynamic execution framework for your Redis data. + +Consider following example to sync data with MongoDB. + +- Create the below python file and update the MongoDB connection details, database, collection and primary key name to be synced + +```python +# movies-write-behind.py + +# Gears Recipe for a single write behind + +# import redis gears & mongo db libs +from rgsync import RGJSONWriteBehind, RGJSONWriteThrough +from rgsync.Connectors import MongoConnector, MongoConnection + +# change mongodb connection +connection = MongoConnection("", "", "", "", "ENV_MONGODB_CONNECTION_URL") + +# change MongoDB database +db = 'ENV_DB_NAME' + +# change MongoDB collection & it's primary key +collection1Connector = MongoConnector(connection, db, 'ENV_COLLECTION1_NAME', 'ENV_COLLECTION1_PRIMARY_KEY') + +# change redis keys with prefix that must be synced with mongodb collection +RGJSONWriteBehind(GB, keysPrefix='ENV_COLLECTION1_PREFIX_KEY', + connector=collection1Connector, name='Collection1WriteBehind', + version='99.99.99') +``` + +```env +ENV_MONGODB_CONNECTION_URL=mongodb://usrAdmin:passwordAdmin@10.10.20.2:27017/dbSpeedMernDemo?authSource=admin +ENV_DB_NAME=dbSpeedMernDemo +ENV_COLLECTION1_NAME=movies +ENV_COLLECTION1_PRIMARY_KEY=movieId +ENV_COLLECTION1_PREFIX_KEY=movie +``` + +Above code shows keys starting with "movie" in Redis will be synced with "movies" collection of MongoDB + +- Created python file must be loaded in redis server + +```sh +redis-cli rg.pyexecute "`cat movies-write-behind.py`" REQUIREMENTS rgsync pymongo==3.12.0 +``` + +Now insert a json item in to redis starting with the prefix specified in the python file + +```sh +# redis cli command +> JSON.SET movie:123 $ '{"movieId":123,"name":"RRR","isActive": true}' +``` + +- Now, verify whether the json is inserted in MongoDB + +More resources at [Redis gear sync with MongoDB](https://github.com/RedisGears/rgsync/tree/master/examples/mongo),[RG.PYEXECUTE](https://oss.redis.com/redisgears/commands.html#rgpyexecute),[rgsync](https://github.com/RedisGears/rgsync#running-the-recipe),[gears-cli](https://github.com/RedisGears/gears-cli), [RedisGears dynamic script](/howtos/redisgears) + +## Probabilistic queries (Bloom) + +Probabilistic Datatypes Module for Redis + +## Links + +- Join the [community](/community/) +- [Redis Insight](https://redis.com/redis-enterprise/redis-insight/) + +
diff --git a/docusaurus.config.js b/docusaurus.config.js index 49f15734c3f..7e792674ec5 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -56,6 +56,12 @@ module.exports = { title: 'Developer Growth Manager at Redis', image: 'profile_pic_will_johnston.jpg', }, + prasan: { + name: 'Prasan Kumar', + link: 'https://www.linkedin.com/in/prasankumar93/', + title: 'Technical Solutions Developer at Redis', + image: 'profile_pic_prasan_kumar.jpg', + }, ryan: { name: 'Ryan Gray', link: 'https://www.linkedin.com/in/ryan-t-gray/', @@ -211,7 +217,8 @@ module.exports = { position: 'right', }, { - to: '/create/rediscloud', + to: '/howtos/quick-start', + //to: '/create/rediscloud', activeBasePath: 'docs', label: 'Get started', position: 'right', @@ -305,14 +312,14 @@ module.exports = { // Useful if you want to support a single color mode disableSwitch: false, }, - // announcementBar: { - // id: 'redisconf20201cfp', // Any value that will identify this message. - // content: - // 'RedisDays Available Now On-Demand.', - // backgroundColor: '#fff', // Defaults to `#fff`. - // textColor: '#000', // Defaults to `#000`. - // isCloseable: true, // Defaults to `true`. - // }, + // announcementBar: { + // id: 'redisconf20201cfp', // Any value that will identify this message. + // content: + // 'RedisDays Available Now On-Demand.', + // backgroundColor: '#fff', // Defaults to `#fff`. + // textColor: '#000', // Defaults to `#000`. + // isCloseable: true, // Defaults to `true`. + // }, }), presets: [ [ diff --git a/sidebars.js b/sidebars.js index 968c4938fc8..9779f4ec613 100644 --- a/sidebars.js +++ b/sidebars.js @@ -71,6 +71,7 @@ module.exports = { ], }, 'create/homebrew/index-homebrew', + 'create/linux/index-linux', 'create/windows/index-windows', 'create/from-source/index-from-source', 'create/jenkins/index-jenkins', @@ -450,6 +451,7 @@ module.exports = { label: 'HowTos & Tutorials', items: [ 'howtos/index-howtos', + 'howtos/quick-start/index-quick-start', 'howtos/redisearch/index-redisearch', { type: 'category', diff --git a/static/img/profile_pic_prasan_kumar.jpg b/static/img/profile_pic_prasan_kumar.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b1258e026d449e7af99471f86da1f9761813bf70 GIT binary patch literal 14056 zcmbWcWmFtp@HaR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_Lo!^dOT0U5wB02q8m zA(51j*zAn(v6=(cwWTsGk;p)pFSFi#Is@jG3^U5aGTQ^il-`)zY>t%~hL;5}Mdc{UBMPE1#?8DGX{ zB}FGB*mDdE^baF=12L2%)|(O3(@26zXJ@#mL1f$itHEGn&WLEcY{E zr>js}nWQjBHPPW9^C^3oHPH}|@)s9~wos#I-k?Q>pE&=m?07ey(Ub522@D~wx62hv zLd{V5n4RYzX_4C%lZ39CVm(;nUCh|gb;vL22f1HT8_-Z<~mx`kq?P2KXw(#_E6^;Qk?YqZXO(y)I??p(Jx PP{Re2s=n;`ye Date: Wed, 9 Nov 2022 00:41:59 +0530 Subject: [PATCH 02/16] quickstart - redis modules --- .../howtos/quick-start/images/redis-bloom.svg | 14 ++ .../howtos/quick-start/images/redis-graph.svg | 14 ++ .../quick-start/images/redis-insight.svg | 168 ++++++++++++++++++ .../quick-start/images/redis-timeseries.svg | 14 ++ docs/howtos/quick-start/index-quick-start.mdx | 45 +++-- 5 files changed, 245 insertions(+), 10 deletions(-) create mode 100644 docs/howtos/quick-start/images/redis-bloom.svg create mode 100644 docs/howtos/quick-start/images/redis-graph.svg create mode 100644 docs/howtos/quick-start/images/redis-insight.svg create mode 100644 docs/howtos/quick-start/images/redis-timeseries.svg diff --git a/docs/howtos/quick-start/images/redis-bloom.svg b/docs/howtos/quick-start/images/redis-bloom.svg new file mode 100644 index 00000000000..077ce95aa9f --- /dev/null +++ b/docs/howtos/quick-start/images/redis-bloom.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/docs/howtos/quick-start/images/redis-graph.svg b/docs/howtos/quick-start/images/redis-graph.svg new file mode 100644 index 00000000000..770a8b62cd5 --- /dev/null +++ b/docs/howtos/quick-start/images/redis-graph.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/docs/howtos/quick-start/images/redis-insight.svg b/docs/howtos/quick-start/images/redis-insight.svg new file mode 100644 index 00000000000..cdacc650183 --- /dev/null +++ b/docs/howtos/quick-start/images/redis-insight.svg @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/howtos/quick-start/images/redis-timeseries.svg b/docs/howtos/quick-start/images/redis-timeseries.svg new file mode 100644 index 00000000000..093c74125fd --- /dev/null +++ b/docs/howtos/quick-start/images/redis-timeseries.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/docs/howtos/quick-start/index-quick-start.mdx b/docs/howtos/quick-start/index-quick-start.mdx index aa875bd080d..e6c98f2c9c1 100644 --- a/docs/howtos/quick-start/index-quick-start.mdx +++ b/docs/howtos/quick-start/index-quick-start.mdx @@ -135,7 +135,7 @@ Detailed Windows instructions can be viewed [here](/create/windows) -- We can connect to Redis using CLI or **[Redis Insights](https://redis.io/docs/stack/insight/)** (a GUI tool to visualize data & run commands) +- Connect to Redis using CLI or **[RedisInsight](https://redis.io/docs/stack/insight/)** (a GUI tool to visualize data & run commands) + +**RedisInsight** +![RedisInsight](./images/redis-insight.svg) ```sh # syntax 1 : connect using host & port @@ -161,7 +164,7 @@ redis-cli -u redis://LJenkins:p%40ssw0rd@redis-16379.hosted.com:16379/0 ``` -- Basic CLI / RedisInsights workbench commands +- Basic CLI / RedisInsight workbench commands ```sh # syntax : Check specific keys @@ -355,10 +358,10 @@ await client.disconnect(); defaultValue="CLI" values={[ {label: 'CLI/ RedisInsight', value: 'CLI'}, - {label: 'JS (Redis OM)', value: 'REDIS_OM_JS'}, - {label: 'Python (Redis OM)', value: 'REDIS_OM_PYTHON'}, - {label: 'Java (Redis OM)', value: 'REDIS_OM_JAVA'}, - {label: 'C# (Redis OM)', value: 'REDIS_OM_DOTNET'}, + {label: 'Javascript', value: 'REDIS_OM_JS'}, + {label: 'Python', value: 'REDIS_OM_PYTHON'}, + {label: 'Java', value: 'REDIS_OM_JAVA'}, + {label: 'C#', value: 'REDIS_OM_DOTNET'}, ]}> @@ -527,6 +530,8 @@ Watch video [RediSearch (RedisConf 2020)](https://www.youtube.com/watch?v=9R29LL +[Redis OM Node](https://github.com/redis/redis-om-node) client library is used in below example but you can also use [Node Redis](https://github.com/redis/node-redis), [IO Redis](https://github.com/luin/ioredis) or any other supported [client](https://redis.io/resources/clients/) + ```sh # install RedisOM in the project npm install redis-om --save @@ -745,13 +750,33 @@ Now insert a json item in to redis starting with the prefix specified in the pyt More resources at [Redis gear sync with MongoDB](https://github.com/RedisGears/rgsync/tree/master/examples/mongo),[RG.PYEXECUTE](https://oss.redis.com/redisgears/commands.html#rgpyexecute),[rgsync](https://github.com/RedisGears/rgsync#running-the-recipe),[gears-cli](https://github.com/RedisGears/gears-cli), [RedisGears dynamic script](/howtos/redisgears) -## Probabilistic queries (Bloom) +## Probabilistic queries + +Redis bloom adds probabilistic Datatypes Module for Redis. + +![RedisBloom](./images/redis-bloom.svg) + +More details in [docs](https://redis.io/docs/stack/bloom/) + +## Graph queries + +RedisGraph is a graph database built on Redis. + +![RedisGraph](./images/redis-graph.svg) + +More details in [docs](https://redis.io/docs/stack/graph/) + +## Timeseries queries + +RedisTimeSeries is used to ingest and query time series data with Redis + +![RedisTimeSeries](./images/redis-timeseries.svg) -Probabilistic Datatypes Module for Redis +More details in [docs](https://redis.io/docs/stack/timeseries/) ## Links - Join the [community](/community/) -- [Redis Insight](https://redis.com/redis-enterprise/redis-insight/) +- [RedisInsight](https://redis.com/redis-enterprise/redis-insight/) From fcd0a5dee65fe12b2d6e041f7a7fadc53e2f0a9d Mon Sep 17 00:00:00 2001 From: PrasanKumar Date: Mon, 14 Nov 2022 16:18:55 +0530 Subject: [PATCH 03/16] commenting quick start navigation --- docusaurus.config.js | 4 ++-- sidebars.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index 7e792674ec5..3817c8749d4 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -217,8 +217,8 @@ module.exports = { position: 'right', }, { - to: '/howtos/quick-start', - //to: '/create/rediscloud', + //to: '/howtos/quick-start', + to: '/create/rediscloud', activeBasePath: 'docs', label: 'Get started', position: 'right', diff --git a/sidebars.js b/sidebars.js index 9779f4ec613..86efb905623 100644 --- a/sidebars.js +++ b/sidebars.js @@ -451,7 +451,7 @@ module.exports = { label: 'HowTos & Tutorials', items: [ 'howtos/index-howtos', - 'howtos/quick-start/index-quick-start', + // 'howtos/quick-start/index-quick-start', 'howtos/redisearch/index-redisearch', { type: 'category', From c9e14a3e76400223af46af9193e053f0abd604b2 Mon Sep 17 00:00:00 2001 From: William Johnston Date: Mon, 14 Nov 2022 09:46:06 -0800 Subject: [PATCH 04/16] Adding partials to break out quick-start --- .../quick-start/cli/_cli-basic-querying.mdx | 100 +++ .../cli/_cli-secondary-indexing.mdx | 160 +++++ .../csharp/_csharp-basic-querying.mdx | 1 + .../csharp/_csharp-secondary-indexing.mdx | 1 + docs/howtos/quick-start/index-quick-start.mdx | 608 ++---------------- .../quick-start/java/_java-basic-querying.mdx | 1 + .../java/_java-secondary-indexing.mdx | 1 + .../quick-start/node/_node-basic-querying.mdx | 87 +++ .../node/_node-secondary-indexing.mdx | 146 +++++ .../python/_python-basic-querying.mdx | 62 ++ .../python/_python-secondary-indexing.mdx | 54 ++ .../quick-start/setup/_docker-setup.mdx | 18 + .../howtos/quick-start/setup/_linux-setup.mdx | 30 + .../howtos/quick-start/setup/_macos-setup.mdx | 10 + .../quick-start/setup/_windows-setup.mdx | 21 + 15 files changed, 732 insertions(+), 568 deletions(-) create mode 100644 docs/howtos/quick-start/cli/_cli-basic-querying.mdx create mode 100644 docs/howtos/quick-start/cli/_cli-secondary-indexing.mdx create mode 100644 docs/howtos/quick-start/csharp/_csharp-basic-querying.mdx create mode 100644 docs/howtos/quick-start/csharp/_csharp-secondary-indexing.mdx create mode 100644 docs/howtos/quick-start/java/_java-basic-querying.mdx create mode 100644 docs/howtos/quick-start/java/_java-secondary-indexing.mdx create mode 100644 docs/howtos/quick-start/node/_node-basic-querying.mdx create mode 100644 docs/howtos/quick-start/node/_node-secondary-indexing.mdx create mode 100644 docs/howtos/quick-start/python/_python-basic-querying.mdx create mode 100644 docs/howtos/quick-start/python/_python-secondary-indexing.mdx create mode 100644 docs/howtos/quick-start/setup/_docker-setup.mdx create mode 100644 docs/howtos/quick-start/setup/_linux-setup.mdx create mode 100644 docs/howtos/quick-start/setup/_macos-setup.mdx create mode 100644 docs/howtos/quick-start/setup/_windows-setup.mdx diff --git a/docs/howtos/quick-start/cli/_cli-basic-querying.mdx b/docs/howtos/quick-start/cli/_cli-basic-querying.mdx new file mode 100644 index 00000000000..29fcb0f1759 --- /dev/null +++ b/docs/howtos/quick-start/cli/_cli-basic-querying.mdx @@ -0,0 +1,100 @@ + +- Connect to Redis using CLI or **[RedisInsight](https://redis.io/docs/stack/insight/)** (a GUI tool to visualize data & run commands) + +**RedisInsight** +![RedisInsight](../images/redis-insight.svg) + +```sh +# syntax 1 : connect using host & port +redis-cli -h host -p port -a password + +# example 1 +redis-cli -h redis15.localnet.org -p 6390 -a myUnguessablePassword + +# syntax 2 : connect using uri +redis-cli -u redis://user:password@host:port/dbnum + +# example 2 +redis-cli -u redis://LJenkins:p%40ssw0rd@redis-16379.hosted.com:16379/0 + +``` + +- Basic CLI / RedisInsight workbench commands + +```sh +# syntax : Check specific keys +keys pattern + +# example +keys * + +#------------ +# syntax : Check number of keys in database +dbsize + +#------------ +# syntax : set a key value +set key value EX expirySeconds + +# example +set company redis EX 60 + +#------------ +# syntax : get value by key +get key + +# example +get company + +#------------ +# syntax : delete keys +del key1 key2 key3 ... keyN + +# example +del company + +#------------ +# syntax : Check if key exists +exists key1 + +# example +exists company + +#------------ +# syntax : set expiry to key +expire key seconds + +# example +expire lastname 60 + +#------------ +# syntax : remove expiry from key +persist key + +# example +persist lastname + +#------------ +# syntax : find (remaining) time to live of a key +ttl key + +# example +ttl lastname + +#------------ +# syntax : increment a number +incr key + +# example +incr counter + +#------------ +# syntax : decrement a number +decr key + +# example +decr counter +``` + +Detailed CLI instructions can be viewed [here](https://redis.io/docs/manual/cli/) and +commands can be checked [here](https://redis.io/commands/) diff --git a/docs/howtos/quick-start/cli/_cli-secondary-indexing.mdx b/docs/howtos/quick-start/cli/_cli-secondary-indexing.mdx new file mode 100644 index 00000000000..0326c6db324 --- /dev/null +++ b/docs/howtos/quick-start/cli/_cli-secondary-indexing.mdx @@ -0,0 +1,160 @@ + +**RedisJSON** adds JSON data type for Redis. + +```sh +# syntax : set an object value to a key +JSON.SET objKey $ value + +# example +JSON.SET person $ '{"name":"Leonard Cohen","dob":1478476800,"isActive": true, "hobbies":["music", "cricket"]}' + +#------------ +# syntax : get object value of a key +JSON.GET objKey $ + +# example +JSON.GET person $ + +#------------ +# syntax : find object key length +JSON.OBJLEN objKey $ + +# example +JSON.OBJLEN person $ + +#------------ +# syntax : find object keys +JSON.OBJKEYS objKey $ + +# example +JSON.OBJKEYS person $ + +#------------ +# syntax : update nested property +JSON.SET objKey $.prop value + +# example +JSON.SET person $.name '"Alex"' + +#------------ +# syntax : update nested array +JSON.SET objKey $.arrayProp fullValue +JSON.SET objKey $.arrayProp[index] value + +# example +JSON.SET person $.hobbies '["music", "cricket"]' +JSON.SET person $.hobbies[1] '"dance"' + +#------------ +# syntax : remove nested array item by index +JSON.ARRPOP objKey $.arrayProp index + +# example +JSON.ARRPOP person $.hobbies 1 +``` + +More RedisJSON details can be found in [docs](https://redis.io/docs/stack/json/) + +--- + +**Redis Search** is a query and indexing engine for Redis, providing secondary indexing, full-text search and aggregations capabilities. + +- We have to create index on schema to be able to search on its data + +```sh +# syntax +FT.CREATE {index_name} ON JSON SCHEMA {json_path} AS {attribute} {type} +# note : attribute = logical name, json_path = JSONPath expressions + +# example +FT.CREATE userIdx ON JSON SCHEMA $.user.name AS name TEXT $.user.hobbies AS hobbies TAG $.user.age as age NUMERIC +# note : Can search by any attribute mentioned in the above index. +``` + +- More details on Indexing JSON can be found [here](https://redis.io/docs/stack/search/indexing_json/) + +Once index is created, any pre-existing/ new/ modified JSON document is automatically indexed. + +```json +//sample json document +{ + "user": { + "name": "John Smith", + "hobbies": "foo,bar", + "age": 23 + } +} +``` + +```sh +# adding JSON document +JSON.SET myDoc $ '{"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}' +``` + +- Search + +```sh +# search all user documents with name 'John' +FT.SEARCH userIdx '@name:(John)' + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$" + 2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}" +``` + +- Search & project required fields + +```sh +# search documents with name 'John' & project only age field +FT.SEARCH userIdx '@name:(John)' RETURN 1 $.user.age + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$.user.age" + 2) "23" +``` + +```sh +# project multiple fields +FT.SEARCH userIdx '@name:(John)' RETURN 2 $.user.age $.user.name + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$.user.age" + 2) "23" + 3) "$.user.name" + 4) "John Smith" + +#------------ +# project with alias name +FT.SEARCH userIdx '@name:(John)' RETURN 3 $.user.age AS userAge + +1) (integer) 1 +2) "myDoc" +3) 1) "userAge" + 2) "23" +#------------ + +# multi field query +FT.SEARCH userIdx '@name:(John) @hobbies:{foo | me} @age:[20 30]' + +# output +1) (integer) 1 +2) "myDoc" +3) 1) "$" + 2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}" +``` + +More details on [query syntax](https://redis.io/docs/stack/search/reference/query_syntax/) + +- Drop index + +```sh +FT.DROPINDEX userIdx +``` + +Watch video [RediSearch (RedisConf 2020)](https://www.youtube.com/watch?v=9R29LLWquME), also more details can be found in [docs](https://redis.io/docs/stack/search/) diff --git a/docs/howtos/quick-start/csharp/_csharp-basic-querying.mdx b/docs/howtos/quick-start/csharp/_csharp-basic-querying.mdx new file mode 100644 index 00000000000..0ec8b083d10 --- /dev/null +++ b/docs/howtos/quick-start/csharp/_csharp-basic-querying.mdx @@ -0,0 +1 @@ +TODO: Examples coming soon diff --git a/docs/howtos/quick-start/csharp/_csharp-secondary-indexing.mdx b/docs/howtos/quick-start/csharp/_csharp-secondary-indexing.mdx new file mode 100644 index 00000000000..0ec8b083d10 --- /dev/null +++ b/docs/howtos/quick-start/csharp/_csharp-secondary-indexing.mdx @@ -0,0 +1 @@ +TODO: Examples coming soon diff --git a/docs/howtos/quick-start/index-quick-start.mdx b/docs/howtos/quick-start/index-quick-start.mdx index e6c98f2c9c1..2dbbc57da36 100644 --- a/docs/howtos/quick-start/index-quick-start.mdx +++ b/docs/howtos/quick-start/index-quick-start.mdx @@ -11,6 +11,28 @@ import TabItem from '@theme/TabItem'; import useBaseUrl from '@docusaurus/useBaseUrl'; import Authors from '@site/src/theme/Authors'; +import DockerSetup from './setup/_docker-setup.mdx'; +import LinuxSetup from './setup/_linux-setup.mdx'; +import MacOsSetup from './setup/_macos-setup.mdx'; +import WindowsSetup from './setup/_windows-setup.mdx'; + +import CliBasicQuerying from './cli/_cli-basic-querying.mdx'; +import CliSecondaryIndexing from './cli/_cli-secondary-indexing.mdx'; + +import NodeBasicQuerying from './node/_node-basic-querying.mdx'; +import NodeSecondaryIndexing from './node/_node-secondary-indexing.mdx'; + +import PythonBasicQuerying from './python/_python-basic-querying.mdx'; +import PythonSecondaryIndexing from './python/_python-secondary-indexing.mdx'; + + +import JavaBasicQuerying from './java/_java-basic-querying.mdx'; +import JavaSecondaryIndexing from './java/_java-secondary-indexing.mdx'; + + +import CSharpBasicQuerying from './csharp/_csharp-basic-querying.mdx'; +import CSharpSecondaryIndexing from './csharp/_csharp-secondary-indexing.mdx'; +
@@ -35,96 +57,24 @@ Use one of the following ways to set up Redis : -```sh -# install redis-stack -brew tap redis-stack/redis-stack -brew install --cask redis-stack - -# start redis-stack -redis-stack-server -``` - -Detailed MacOS instructions can be viewed [here](/create/homebrew/) + -- **Ubuntu** (16.04, 18.04, 20.04) - -```sh -curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg -echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list -sudo apt-get update -sudo apt-get install redis-stack-server -``` - -- **RHEL/ CentOS** (7, 8) - -Create the file /etc/yum.repos.d/redis.repo with the following contents - -``` -[Redis] -name=Redis -baseurl=http://packages.redis.io/rpm/rhel7 -enabled=1 -gpgcheck=1 -``` - -```sh -curl -fsSL https://packages.redis.io/gpg > /tmp/redis.key -sudo rpm --import /tmp/redis.key -sudo yum install epel-release -sudo yum install redis-stack-server -``` - -Detailed Linux instructions can be viewed [here](/create/linux/) + -Below docker run command exposes RedisServer on 6379 and RedisInsight on port 8001. -You can use RedisInsight by pointing your browser to localhost:8001. - -```sh -# install -docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest -``` - -You can use redis-cli to connect to the server. -If you don’t have redis-cli installed locally, you can run it from the Docker container like below: - -```sh -# connect -docker exec -it redis-stack redis-cli -``` - -Detailed Docker instructions can be viewed [here](/create/docker/redis-on-docker) + -Redis is not officially supported on Windows, but can be installed via WSL2 (Windows Subsystem for Linux) for development purpose - -- Enable [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install) to run Ubuntu on Windows and follow below Ubuntu steps - -```sh - sudo apt-add-repository ppa:redislabs/redis - sudo apt-get update - sudo apt-get upgrade - sudo apt-get install redis-server -``` - -``` -# Restart the Redis server -sudo service redis-server restart - -# Connect to Redis -redis-cli -``` - -Detailed Windows instructions can be viewed [here](/create/windows) + @@ -144,210 +94,28 @@ Detailed Windows instructions can be viewed [here](/create/windows) -- Connect to Redis using CLI or **[RedisInsight](https://redis.io/docs/stack/insight/)** (a GUI tool to visualize data & run commands) - -**RedisInsight** -![RedisInsight](./images/redis-insight.svg) - -```sh -# syntax 1 : connect using host & port -redis-cli -h host -p port -a password - -# example 1 -redis-cli -h redis15.localnet.org -p 6390 -a myUnguessablePassword - -# syntax 2 : connect using uri -redis-cli -u redis://user:password@host:port/dbnum - -# example 2 -redis-cli -u redis://LJenkins:p%40ssw0rd@redis-16379.hosted.com:16379/0 - -``` - -- Basic CLI / RedisInsight workbench commands - -```sh -# syntax : Check specific keys -keys pattern - -# example -keys * - -#------------ -# syntax : Check number of keys in database -dbsize - -#------------ -# syntax : set a key value -set key value EX expirySeconds - -# example -set company redis EX 60 - -#------------ -# syntax : get value by key -get key - -# example -get company - -#------------ -# syntax : delete keys -del key1 key2 key3 ... keyN - -# example -del company - -#------------ -# syntax : Check if key exists -exists key1 - -# example -exists company - -#------------ -# syntax : set expiry to key -expire key seconds - -# example -expire lastname 60 - -#------------ -# syntax : remove expiry from key -persist key - -# example -persist lastname - -#------------ -# syntax : find (remaining) time to live of a key -ttl key - -# example -ttl lastname - -#------------ -# syntax : increment a number -incr key - -# example -incr counter - -#------------ -# syntax : decrement a number -decr key - -# example -decr counter -``` - -Detailed CLI instructions can be viewed [here](https://redis.io/docs/manual/cli/) and -commands can be checked [here](https://redis.io/commands/) + -```sh -# install redis in the project -npm install redis --save -``` - -```js -//create client & connect to redis - -import { createClient } from 'redis'; - -const client = createClient({ - //redis[s]://[[username][:password]@][host][:port][/db-number] - url: 'redis://alice:foobared@awesome.redis.server:6380', -}); - -client.on('error', (err) => console.log('Redis Client Error', err)); - -await client.connect(); -``` - -```js -// Check specific keys -const pattern = '*'; -await client.keys(pattern); - -#------------ -// Check number of keys in database -await client.dbsize(); - -#------------ -// set key value -await client.set('key', 'value'); -await client.set('key', 'value', { - EX: 10, - NX: true, -}); - -#------------ -// get value by key -const value = await client.get('key'); - -#------------ -//syntax : delete keys -await client.del('key'); -const keyArr = ['key1', 'key2', 'key3']; -await client.del(...keyArr); - -#------------ -// Check if key exists -await client.exists('key'); - -#------------ -// set expiry to key -const expireInSeconds = 30; -await client.expire('key', expireInSeconds); - -#------------ -// remove expiry from key -await client.persist('key'); - -#------------ -// find (remaining) time to live of a key -await client.ttl('key'); - -#------------ -// increment a number -await client.incr('key'); - -#------------ -// decrement a number -await client.decr('key'); - -#------------ -//use below style for unsupported commands by client library -await client.sendCommand(['SET', 'key', 'value']); -``` - -```js -//graceful disconnecting -await client.quit(); - -//forceful disconnecting -await client.disconnect(); -``` - -- More details at [Github repo](https://github.com/redis/node-redis) and also check Javascript/ NodeJS apps at [Redis Launchpad](https://launchpad.redis.com/) + -- TODO: similar commands to be written + + -- TODO: similar commands to be written + -- TODO: similar commands to be written + @@ -366,328 +134,32 @@ await client.disconnect(); -**RedisJSON** adds JSON data type for Redis. - -```sh -# syntax : set an object value to a key -JSON.SET objKey $ value - -# example -JSON.SET person $ '{"name":"Leonard Cohen","dob":1478476800,"isActive": true, "hobbies":["music", "cricket"]}' - -#------------ -# syntax : get object value of a key -JSON.GET objKey $ - -# example -JSON.GET person $ - -#------------ -# syntax : find object key length -JSON.OBJLEN objKey $ - -# example -JSON.OBJLEN person $ - -#------------ -# syntax : find object keys -JSON.OBJKEYS objKey $ - -# example -JSON.OBJKEYS person $ - -#------------ -# syntax : update nested property -JSON.SET objKey $.prop value - -# example -JSON.SET person $.name '"Alex"' - -#------------ -# syntax : update nested array -JSON.SET objKey $.arrayProp fullValue -JSON.SET objKey $.arrayProp[index] value - -# example -JSON.SET person $.hobbies '["music", "cricket"]' -JSON.SET person $.hobbies[1] '"dance"' - -#------------ -# syntax : remove nested array item by index -JSON.ARRPOP objKey $.arrayProp index - -# example -JSON.ARRPOP person $.hobbies 1 -``` - -More RedisJSON details can be found in [docs](https://redis.io/docs/stack/json/) - ---- - -**Redis Search** is a query and indexing engine for Redis, providing secondary indexing, full-text search and aggregations capabilities. - -- We have to create index on schema to be able to search on its data - -```sh -# syntax -FT.CREATE {index_name} ON JSON SCHEMA {json_path} AS {attribute} {type} -# note : attribute = logical name, json_path = JSONPath expressions - -# example -FT.CREATE userIdx ON JSON SCHEMA $.user.name AS name TEXT $.user.hobbies AS hobbies TAG $.user.age as age NUMERIC -# note : Can search by any attribute mentioned in the above index. -``` - -- More details on Indexing JSON can be found [here](https://redis.io/docs/stack/search/indexing_json/) - -Once index is created, any pre-existing/ new/ modified JSON document is automatically indexed. - -```json -//sample json document -{ - "user": { - "name": "John Smith", - "hobbies": "foo,bar", - "age": 23 - } -} -``` - -```sh -# adding JSON document -JSON.SET myDoc $ '{"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}' -``` - -- Search - -```sh -# search all user documents with name 'John' -FT.SEARCH userIdx '@name:(John)' - -# output -1) (integer) 1 -2) "myDoc" -3) 1) "$" - 2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}" -``` - -- Search & project required fields - -```sh -# search documents with name 'John' & project only age field -FT.SEARCH userIdx '@name:(John)' RETURN 1 $.user.age - -# output -1) (integer) 1 -2) "myDoc" -3) 1) "$.user.age" - 2) "23" -``` - -```sh -# project multiple fields -FT.SEARCH userIdx '@name:(John)' RETURN 2 $.user.age $.user.name - -# output -1) (integer) 1 -2) "myDoc" -3) 1) "$.user.age" - 2) "23" - 3) "$.user.name" - 4) "John Smith" - -#------------ -# project with alias name -FT.SEARCH userIdx '@name:(John)' RETURN 3 $.user.age AS userAge - -1) (integer) 1 -2) "myDoc" -3) 1) "userAge" - 2) "23" -#------------ - -# multi field query -FT.SEARCH userIdx '@name:(John) @hobbies:{foo | me} @age:[20 30]' - -# output -1) (integer) 1 -2) "myDoc" -3) 1) "$" - 2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}" -``` - -More details on [query syntax](https://redis.io/docs/stack/search/reference/query_syntax/) - -- Drop index - -```sh -FT.DROPINDEX userIdx -``` - -Watch video [RediSearch (RedisConf 2020)](https://www.youtube.com/watch?v=9R29LLWquME), also more details can be found in [docs](https://redis.io/docs/stack/search/) + -[Redis OM Node](https://github.com/redis/redis-om-node) client library is used in below example but you can also use [Node Redis](https://github.com/redis/node-redis), [IO Redis](https://github.com/luin/ioredis) or any other supported [client](https://redis.io/resources/clients/) - -```sh -# install RedisOM in the project -npm install redis-om --save -``` - -- create RedisOM Client & connect to redis - -```js -//client.js file - -import { Client } from 'redis-om'; - -// pulls the Redis URL from .env -const url = process.env.REDIS_URL; - -const client = new Client(); -await client.open(url); - -export default client; -``` - -- Create Entity, Schema & Repository - -```js -//person.js file - -import { Entity, Schema } from 'redis-om'; -import client from './client.js'; - -class Person extends Entity {} - -const personSchema = new Schema(Person, { - firstName: { type: 'string' }, - lastName: { type: 'string' }, - age: { type: 'number' }, - verified: { type: 'boolean' }, - location: { type: 'point' }, - locationUpdated: { type: 'date' }, - skills: { type: 'string[]' }, - personalStatement: { type: 'text' }, -}); - -export const personRepository = client.fetchRepository(personSchema); - -//creating index to make person schema searchable -await personRepository.createIndex(); -``` - -```js -import { Router } from 'express'; -import { personRepository } from 'person.js'; -``` - -- Insert sample - -```js -let input = { - firstName: 'Rupert', - lastName: 'Holmes', - age: 75, - verified: false, - location: { - longitude: 45.678, - latitude: 45.678, - }, - locationUpdated: '2022-03-01T12:34:56.123Z', - skills: ['singing', 'songwriting', 'playwriting'], - personalStatement: 'I like piña coladas and walks in the rain', -}; -const person = await personRepository.createAndSave(input); -``` - -- Read sample - -```js -const id = '01FX8N39YVZRCQNAW0R5T53H5T'; -const person = await personRepository.fetch(id); -``` - -- Update sample - -```js -const person = await personRepository.fetch(req.params.id); - -person.firstName = 'Alex'; - -//null to remove that field -person.lastName = null; - -await personRepository.save(person); -``` - -- Update location sample - -```js -const id = '01G79HZ6P3WYWFTY36JF6H3529'; -const longitude = Number('45.678'); -const latitude = 45.678; -const locationUpdated = new Date(); - -const person = await personRepository.fetch(id); -person.location = { longitude, latitude }; -person.locationUpdated = locationUpdated; -await personRepository.save(person); -``` - -- Delete sample - -```js -await personRepository.remove(req.params.id); -``` - -- Search samples - -```js -//get all records of persons -const queryBuilder = personRepository.search(); -const persons = await queryBuilder.return.all(); - -//"multiple and" condition sample -const queryBuilder = personRepository - .search() - .where('verified') - .eq(true) // == - .and('age') - .gte(21) // >= - .and('lastName') - .eq(lastName); -//console.log(queryBuilder.query); -const persons = await queryBuilder.return.all(); - -// "OR" condition sample -const queryBuilder = personRepository - .search() - .where('verified') - .eq(true) - .or((search) => search.where('age').gte(21).and('lastName').eq(lastName)) - .sortAscending('age'); -const persons = await queryBuilder.return.all(); -``` - -Useful links : [Github repo](https://github.com/redis/redis-om-node) and [getting started docs](https://redis.io/docs/stack/get-started/tutorials/stack-node/), -[getting started video](https://www.youtube.com/watch?v=KUfufrwpBkM) and it's [source code](https://github.com/redis-developer/express-redis-om-workshop) + + + + + + + diff --git a/docs/howtos/quick-start/java/_java-basic-querying.mdx b/docs/howtos/quick-start/java/_java-basic-querying.mdx new file mode 100644 index 00000000000..0ec8b083d10 --- /dev/null +++ b/docs/howtos/quick-start/java/_java-basic-querying.mdx @@ -0,0 +1 @@ +TODO: Examples coming soon diff --git a/docs/howtos/quick-start/java/_java-secondary-indexing.mdx b/docs/howtos/quick-start/java/_java-secondary-indexing.mdx new file mode 100644 index 00000000000..0ec8b083d10 --- /dev/null +++ b/docs/howtos/quick-start/java/_java-secondary-indexing.mdx @@ -0,0 +1 @@ +TODO: Examples coming soon diff --git a/docs/howtos/quick-start/node/_node-basic-querying.mdx b/docs/howtos/quick-start/node/_node-basic-querying.mdx new file mode 100644 index 00000000000..fab91a9b4a2 --- /dev/null +++ b/docs/howtos/quick-start/node/_node-basic-querying.mdx @@ -0,0 +1,87 @@ + +```sh +# install redis in the project +npm install redis --save +``` + +```js +//create client & connect to redis + +import { createClient } from 'redis'; + +const client = createClient({ + //redis[s]://[[username][:password]@][host][:port][/db-number] + url: 'redis://alice:foobared@awesome.redis.server:6380', +}); + +client.on('error', (err) => console.log('Redis Client Error', err)); + +await client.connect(); +``` + +```js +// Check specific keys +const pattern = '*'; +await client.keys(pattern); + +#------------ +// Check number of keys in database +await client.dbsize(); + +#------------ +// set key value +await client.set('key', 'value'); +await client.set('key', 'value', { + EX: 10, + NX: true, +}); + +#------------ +// get value by key +const value = await client.get('key'); + +#------------ +//syntax : delete keys +await client.del('key'); +const keyArr = ['key1', 'key2', 'key3']; +await client.del(...keyArr); + +#------------ +// Check if key exists +await client.exists('key'); + +#------------ +// set expiry to key +const expireInSeconds = 30; +await client.expire('key', expireInSeconds); + +#------------ +// remove expiry from key +await client.persist('key'); + +#------------ +// find (remaining) time to live of a key +await client.ttl('key'); + +#------------ +// increment a number +await client.incr('key'); + +#------------ +// decrement a number +await client.decr('key'); + +#------------ +//use below style for unsupported commands by client library +await client.sendCommand(['SET', 'key', 'value']); +``` + +```js +//graceful disconnecting +await client.quit(); + +//forceful disconnecting +await client.disconnect(); +``` + +- More details at [Github repo](https://github.com/redis/node-redis) and also check Javascript/ NodeJS apps at [Redis Launchpad](https://launchpad.redis.com/) diff --git a/docs/howtos/quick-start/node/_node-secondary-indexing.mdx b/docs/howtos/quick-start/node/_node-secondary-indexing.mdx new file mode 100644 index 00000000000..35aa613fb22 --- /dev/null +++ b/docs/howtos/quick-start/node/_node-secondary-indexing.mdx @@ -0,0 +1,146 @@ + +[Redis OM Node](https://github.com/redis/redis-om-node) client library is used in below example but you can also use [Node Redis](https://github.com/redis/node-redis), [IO Redis](https://github.com/luin/ioredis) or any other supported [client](https://redis.io/resources/clients/) + +```sh +# install RedisOM in the project +npm install redis-om --save +``` + +- create RedisOM Client & connect to redis + +```js +//client.js file + +import { Client } from 'redis-om'; + +// pulls the Redis URL from .env +const url = process.env.REDIS_URL; + +const client = new Client(); +await client.open(url); + +export default client; +``` + +- Create Entity, Schema & Repository + +```js +//person.js file + +import { Entity, Schema } from 'redis-om'; +import client from './client.js'; + +class Person extends Entity {} + +const personSchema = new Schema(Person, { + firstName: { type: 'string' }, + lastName: { type: 'string' }, + age: { type: 'number' }, + verified: { type: 'boolean' }, + location: { type: 'point' }, + locationUpdated: { type: 'date' }, + skills: { type: 'string[]' }, + personalStatement: { type: 'text' }, +}); + +export const personRepository = client.fetchRepository(personSchema); + +//creating index to make person schema searchable +await personRepository.createIndex(); +``` + +```js +import { Router } from 'express'; +import { personRepository } from 'person.js'; +``` + +- Insert sample + +```js +let input = { + firstName: 'Rupert', + lastName: 'Holmes', + age: 75, + verified: false, + location: { + longitude: 45.678, + latitude: 45.678, + }, + locationUpdated: '2022-03-01T12:34:56.123Z', + skills: ['singing', 'songwriting', 'playwriting'], + personalStatement: 'I like piña coladas and walks in the rain', +}; +const person = await personRepository.createAndSave(input); +``` + +- Read sample + +```js +const id = '01FX8N39YVZRCQNAW0R5T53H5T'; +const person = await personRepository.fetch(id); +``` + +- Update sample + +```js +const person = await personRepository.fetch(req.params.id); + +person.firstName = 'Alex'; + +//null to remove that field +person.lastName = null; + +await personRepository.save(person); +``` + +- Update location sample + +```js +const id = '01G79HZ6P3WYWFTY36JF6H3529'; +const longitude = Number('45.678'); +const latitude = 45.678; +const locationUpdated = new Date(); + +const person = await personRepository.fetch(id); +person.location = { longitude, latitude }; +person.locationUpdated = locationUpdated; +await personRepository.save(person); +``` + +- Delete sample + +```js +await personRepository.remove(req.params.id); +``` + +- Search samples + +```js +//get all records of persons +const queryBuilder = personRepository.search(); +const persons = await queryBuilder.return.all(); + +//"multiple and" condition sample +const queryBuilder = personRepository + .search() + .where('verified') + .eq(true) // == + .and('age') + .gte(21) // >= + .and('lastName') + .eq(lastName); +//console.log(queryBuilder.query); +const persons = await queryBuilder.return.all(); + +// "OR" condition sample +const queryBuilder = personRepository + .search() + .where('verified') + .eq(true) + .or((search) => search.where('age').gte(21).and('lastName').eq(lastName)) + .sortAscending('age'); +const persons = await queryBuilder.return.all(); +``` + +Useful links : [Github repo](https://github.com/redis/redis-om-node) and [getting started docs](https://redis.io/docs/stack/get-started/tutorials/stack-node/), +[getting started video](https://www.youtube.com/watch?v=KUfufrwpBkM) and it's [source code](https://github.com/redis-developer/express-redis-om-workshop) diff --git a/docs/howtos/quick-start/python/_python-basic-querying.mdx b/docs/howtos/quick-start/python/_python-basic-querying.mdx new file mode 100644 index 00000000000..06f59090d94 --- /dev/null +++ b/docs/howtos/quick-start/python/_python-basic-querying.mdx @@ -0,0 +1,62 @@ + +```sh +# install redis in the project +pip install redis +``` + +```python +import redis + +pool = redis.ConnectionPool(host='localhost', port=6379, db=0) +r = redis.Redis(connection_pool=pool) + +# Check specific keys +r.keys('*') + +#------------ +# Check number of keys in database +r.dbsize() + +#------------ +# set key value +r.set('key', 'value') +r.set('key', 'value', ex=10, nx=True) + +#------------ +# get value by key +value = r.get('key') + +#------------ +# syntax : delete keys +r.delete('key') +r.delete('key1', 'key2', 'key3') + +#------------ +# Check if key exists +r.exists('key') + +#------------ +# set expiry to key +expireInSeconds = 30 +r.expire('key', expireInSeconds) + +#------------ +# remove expiry from key +r.persist('key') + +#------------ +# find (remaining) time to live of a key +r.ttl('key') + +#------------ +# increment a number +r.incr('key') + +#------------ +# decrement a number +r.decr('key') + +#------------ +# use below style for unsupported commands by client library +r.execute_command('SET', 'key', 'value') +``` diff --git a/docs/howtos/quick-start/python/_python-secondary-indexing.mdx b/docs/howtos/quick-start/python/_python-secondary-indexing.mdx new file mode 100644 index 00000000000..6a7477428c7 --- /dev/null +++ b/docs/howtos/quick-start/python/_python-secondary-indexing.mdx @@ -0,0 +1,54 @@ + +```sh +# install Redis OM in the project +pip install redis-om +``` + +Create an embedded JSON model + +```python +import datetime +from typing import Optional + +from redis_om import ( + EmbeddedJsonModel, + JsonModel, + Field, + Migrator, +) + + +class Address(EmbeddedJsonModel): + address_line_1: str + address_line_2: Optional[str] + city: str = Field(index=True) + state: str = Field(index=True) + country: str + postal_code: str = Field(index=True) + + +class Customer(JsonModel): + first_name: str = Field(index=True) + last_name: str = Field(index=True) + email: str = Field(index=True) + join_date: datetime.date + age: int = Field(index=True) + bio: Optional[str] = Field(index=True, full_text_search=True, + default="") + + # Creates an embedded model. + address: Address + + +# With these two models and a Redis deployment with the RedisJSON +# module installed, we can run queries like the following. + +# Before running queries, we need to run migrations to set up the +# indexes that Redis OM will use. You can also use the `migrate` +# CLI tool for this! +Migrator().run() + +# Find all customers who live in San Antonio, TX +Customer.find(Customer.address.city == "San Antonio", + Customer.address.state == "TX") +``` \ No newline at end of file diff --git a/docs/howtos/quick-start/setup/_docker-setup.mdx b/docs/howtos/quick-start/setup/_docker-setup.mdx new file mode 100644 index 00000000000..3a8fd91699d --- /dev/null +++ b/docs/howtos/quick-start/setup/_docker-setup.mdx @@ -0,0 +1,18 @@ + +Below docker run command exposes RedisServer on 6379 and RedisInsight on port 8001. +You can use RedisInsight by pointing your browser to localhost:8001. + +```sh +# install +docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest +``` + +You can use redis-cli to connect to the server. +If you don’t have redis-cli installed locally, you can run it from the Docker container like below: + +```sh +# connect +docker exec -it redis-stack redis-cli +``` + +Detailed Docker instructions can be viewed [here](/create/docker/redis-on-docker) diff --git a/docs/howtos/quick-start/setup/_linux-setup.mdx b/docs/howtos/quick-start/setup/_linux-setup.mdx new file mode 100644 index 00000000000..7a696a21571 --- /dev/null +++ b/docs/howtos/quick-start/setup/_linux-setup.mdx @@ -0,0 +1,30 @@ + +- **Ubuntu** (16.04, 18.04, 20.04) + +```sh +curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list +sudo apt-get update +sudo apt-get install redis-stack-server +``` + +- **RHEL/ CentOS** (7, 8) + +Create the file /etc/yum.repos.d/redis.repo with the following contents + +``` +[Redis] +name=Redis +baseurl=http://packages.redis.io/rpm/rhel7 +enabled=1 +gpgcheck=1 +``` + +```sh +curl -fsSL https://packages.redis.io/gpg > /tmp/redis.key +sudo rpm --import /tmp/redis.key +sudo yum install epel-release +sudo yum install redis-stack-server +``` + +Detailed Linux instructions can be viewed [here](/create/linux/) diff --git a/docs/howtos/quick-start/setup/_macos-setup.mdx b/docs/howtos/quick-start/setup/_macos-setup.mdx new file mode 100644 index 00000000000..58882d589ec --- /dev/null +++ b/docs/howtos/quick-start/setup/_macos-setup.mdx @@ -0,0 +1,10 @@ +```sh +# install redis-stack +brew tap redis-stack/redis-stack +brew install --cask redis-stack + +# start redis-stack +redis-stack-server +``` + +Detailed MacOS instructions can be viewed [here](/create/homebrew/) diff --git a/docs/howtos/quick-start/setup/_windows-setup.mdx b/docs/howtos/quick-start/setup/_windows-setup.mdx new file mode 100644 index 00000000000..c3b4fc145b8 --- /dev/null +++ b/docs/howtos/quick-start/setup/_windows-setup.mdx @@ -0,0 +1,21 @@ + +Redis is not officially supported on Windows, but can be installed via WSL2 (Windows Subsystem for Linux) for development purpose + +- Enable [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install) to run Ubuntu on Windows and follow below Ubuntu steps + +```sh + sudo apt-add-repository ppa:redislabs/redis + sudo apt-get update + sudo apt-get upgrade + sudo apt-get install redis-server +``` + +``` +# Restart the Redis server +sudo service redis-server restart + +# Connect to Redis +redis-cli +``` + +Detailed Windows instructions can be viewed [here](/create/windows) From e918c4fb33fbe358774d34244c7ce284ec07f47e Mon Sep 17 00:00:00 2001 From: William Johnston Date: Thu, 29 Dec 2022 12:04:54 -0800 Subject: [PATCH 05/16] finishing python doc, adjusting node doc to match message, setting up language groups for tabs --- .../quick-start/index-quick-start-old.mdx | 826 ------------------ docs/howtos/quick-start/index-quick-start.mdx | 48 +- .../quick-start/node/_node-basic-querying.mdx | 2 +- .../node/_node-secondary-indexing.mdx | 42 +- .../python/_python-basic-querying.mdx | 2 + .../python/_python-secondary-indexing.mdx | 125 ++- sidebars.js | 6 +- 7 files changed, 158 insertions(+), 893 deletions(-) delete mode 100644 docs/howtos/quick-start/index-quick-start-old.mdx diff --git a/docs/howtos/quick-start/index-quick-start-old.mdx b/docs/howtos/quick-start/index-quick-start-old.mdx deleted file mode 100644 index ed46e90d6d4..00000000000 --- a/docs/howtos/quick-start/index-quick-start-old.mdx +++ /dev/null @@ -1,826 +0,0 @@ ---- -id: index-quick-start-old -title: Quick Start -sidebar_label: Quick Start Old -slug: /howtos/quick-start-old -authors: [prasan] ---- - -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import useBaseUrl from '@docusaurus/useBaseUrl'; - -
- -## Setup Redis - -Use one of the following ways to set up Redis : - -- **Cloud** : Hosted and serverless database-as-a-service (DBaaS). The fastest way to deploy Redis Enterprise via Amazon AWS, Google Cloud Platform or Microsoft Azure. - - [Getting Started](/create/rediscloud), [Videos](https://www.youtube.com/playlist?list=PL83Wfqi-zYZG6uGxBagsbqjpsi2XBEj1K), - [Free Signup](https://app.redislabs.com/#/login) -- **Manual Software** : A self-managed data platform that unlocks the full potential of Redis at enterprise scale on various operating systems like Mac OS, Windows or Linux. - - - - - -```sh -# install redis-stack -brew tap redis-stack/redis-stack -brew install --cask redis-stack - -# start redis-stack -redis-stack-server -``` - -Detailed MacOS instructions can be viewed [here](/create/homebrew/) - - - - - -- **Ubuntu** (16.04, 18.04, 20.04) - -```sh -curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg -echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list -sudo apt-get update -sudo apt-get install redis-stack-server -``` - -- **RHEL/ CentOS** (7, 8) - -Create the file /etc/yum.repos.d/redis.repo with the following contents - -``` -[Redis] -name=Redis -baseurl=http://packages.redis.io/rpm/rhel7 -enabled=1 -gpgcheck=1 -``` - -```sh -curl -fsSL https://packages.redis.io/gpg > /tmp/redis.key -sudo rpm --import /tmp/redis.key -sudo yum install epel-release -sudo yum install redis-stack-server -``` - -Detailed Linux instructions can be viewed [here](https://redis.io/docs/stack/get-started/install/linux/) - - - - -Below docker run command exposes RedisServer on 6379 and RedisInsight on port 8001. -You can use RedisInsight by pointing your browser to localhost:8001. - -```sh -# install -docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest -``` - -You can use redis-cli to connect to the server. -If you don’t have redis-cli installed locally, you can run it from the Docker container like below: - -```sh -# connect -docker exec -it redis-stack redis-cli -``` - -Detailed Docker instructions can be viewed [here](/create/docker/redis-on-docker) - - - - - -**(TODO : - No redis stack example)** - -Redis is not officially supported on Windows, but can be installed via WSL2 (Windows Subsystem for Linux) for development purpose - -- Enable [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install) to run Ubuntu on Windows and follow below Ubuntu steps - -```sh -curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg - -echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list - -sudo apt-get update -sudo apt-get install redis -``` - -``` -# start the Redis server -sudo service redis-server start - -# Connect to Redis -redis-cli -``` - -Detailed Windows instructions can be viewed [here](/create/windows) **TODO : outdated respective to io site?** - - - - - -## Basic Querying - - - - - -- We can connect to Redis using CLI or **[Redis Insights](https://redis.io/docs/stack/insight/)** (a GUI tool to visualize data & run commands) - -```sh -# syntax 1 : connect using host & port -redis-cli -h host -p port -a password - -# example 1 -redis-cli -h redis15.localnet.org -p 6390 -a myUnguessablePassword - -# syntax 2 : connect using uri -redis-cli -u redis://user:password@host:port/dbnum - -# example 2 -redis-cli -u redis://LJenkins:p%40ssw0rd@redis-16379.hosted.com:16379/0 - -``` - -- Basic CLI / RedisInsights workbench commands - -```sh -# syntax : Check specific keys -keys pattern - -# example -keys * - -#------------ -# syntax : Check number of keys in database -dbsize - -#------------ -# syntax : set a key value -set key value EX expirySeconds - -# example -set company redis EX 60 - -#------------ -# syntax : get value by key -get key - -# example -get company - -#------------ -# syntax : delete keys -del key1 key2 key3 ... keyN - -# example -del company - -#------------ -# syntax : Check if key exists -exists key1 - -# example -exists company - -#------------ -# syntax : set expiry to key -expire key seconds - -# example -expire lastname 60 - -#------------ -# syntax : remove expiry from key -persist key - -# example -persist lastname - -#------------ -# syntax : find (remaining) time to live of a key -ttl key - -# example -ttl lastname - -#------------ -# syntax : increment a number -incr key - -# example -incr counter - -#------------ -# syntax : decrement a number -decr key - -# example -decr counter -``` - -Detailed CLI instructions can be viewed [here](https://redis.io/docs/manual/cli/) and -commands can be checked [here](https://redis.io/commands/) - - - - - -```sh -# install redis in the project -npm install redis --save -``` - -```js -//create client & connect to redis - -import { createClient } from 'redis'; - -const client = createClient({ - //redis[s]://[[username][:password]@][host][:port][/db-number] - url: 'redis://alice:foobared@awesome.redis.server:6380', -}); - -client.on('error', (err) => console.log('Redis Client Error', err)); - -await client.connect(); -``` - -```js -// Check specific keys -const pattern = '*'; -await client.keys(pattern); - -#------------ -// Check number of keys in database -await client.dbsize(); - -#------------ -// set key value -await client.set('key', 'value'); -await client.set('key', 'value', { - EX: 10, - NX: true, -}); - -#------------ -// get value by key -const value = await client.get('key'); - -#------------ -//syntax : delete keys -await client.del('key'); -const keyArr = ['key1', 'key2', 'key3']; -await client.del(...keyArr); - -#------------ -// Check if key exists -await client.exists('key'); - -#------------ -// set expiry to key -const expireInSeconds = 30; -await client.expire('key', expireInSeconds); - -#------------ -// remove expiry from key -await client.persist('key'); - -#------------ -// find (remaining) time to live of a key -await client.ttl('key'); - -#------------ -// increment a number -await client.incr('key'); - -#------------ -// decrement a number -await client.decr('key'); - -#------------ -//use below style for unsupported commands by client library -await client.sendCommand(['SET', 'key', 'value']); -``` - -```js -//graceful disconnecting -await client.quit(); - -//forceful disconnecting -await client.disconnect(); -``` - -- More details at [Github repo](https://github.com/redis/node-redis) and also check Javascript/ NodeJS apps at [Redis Launchpad](https://launchpad.redis.com/) - - - -- TODO: similar commands to be written - - - - -- TODO: similar commands to be written - - - - -- TODO: similar commands to be written - - - - -## Redis Modules - - - - - -RedisJSON module adds JSON data type for Redis. - -- Example : Object type - -```sh -# syntax : set an object value to a key -JSON.SET objKey $ value - -# example -JSON.SET person $ '{"name":"Leonard Cohen","dob":1478476800,"isActive": true, "hobbies":["music", "cricket"]}' - -#------------ -# syntax : get object value of a key -JSON.GET objKey $ - -# example -JSON.GET person $ - -#------------ -# syntax : find object key length -JSON.OBJLEN objKey $ - -# example -JSON.OBJLEN person $ - -#------------ -# syntax : find object keys -JSON.OBJKEYS objKey $ - -# example -JSON.OBJKEYS person $ - -#------------ -# syntax : update nested property -JSON.SET objKey $.prop value - -# example -JSON.SET person $.name '"Alex"' - -#------------ -# syntax : update nested array -JSON.SET objKey $.arrayProp fullValue -JSON.SET objKey $.arrayProp[index] value - -# example -JSON.SET person $.hobbies '["music", "cricket"]' -JSON.SET person $.hobbies[1] '"dance"' - -#------------ -# syntax : remove nested array item by index -JSON.ARRPOP objKey $.arrayProp index - -# example -JSON.ARRPOP person $.hobbies 1 -``` - -- Example : String type - -```sh -# syntax : set & get -JSON.SET key path value -JSON.GET key path - -# example -JSON.SET foo $ '"bar"' -JSON.GET foo $ - -#------------ -# syntax : string append -JSON.STRAPPEND key path value - -# example -JSON.STRAPPEND foo $ '"baz"' - -#------------ -# syntax : string length -JSON.STRLEN key path - -# example -JSON.STRLEN foo $ -``` - -- Example : Number type - -```sh -# syntax : set & get -JSON.SET key path value -JSON.GET key path - -# example -JSON.SET num $ 0 -JSON.GET num $ - -#------------ -# syntax : number increment by -JSON.NUMINCRBY key path value - -# example -JSON.NUMINCRBY num $ 1 -JSON.NUMINCRBY num $ 1.5 -JSON.NUMINCRBY num $ -0.75 -``` - -- Example : Array type - -```sh -# syntax : set & get -JSON.SET key path value -JSON.GET key path - -# example -JSON.SET myArray $ '[ true, { "answer": 42 }, null ]' -JSON.GET myArray $ - -#------------ -# syntax : get array item by index -JSON.GET key $[index]] - -# example -JSON.GET myArray $[1] -JSON.GET myArray $[1].answer - -#------------ -# syntax : delete array item by index -JSON.DEL key path -JSON.ARRPOP key path index - -# example -JSON.DEL myArray $[0] -JSON.ARRPOP myArray $ 0 - -#------------ -# syntax : append items to array -JSON.ARRAPPEND key path value1 value2 valueN - -# example -JSON.ARRAPPEND myArray $ '"A"' - -#------------ -# syntax : insert items to array at index -JSON.ARRINSERT key path index value1 value2 valueN - -# example -JSON.ARRINSERT myArray $ 0 '"C"' '"D"' - -#------------ -# syntax : Trims an array to specific inclusive range. -JSON.ARRTRIM key path start stop - -# example -JSON.ARRTRIM myArray $ 0 2 -``` - -More RedisJSON details can be found in [docs](https://redis.io/docs/stack/json/) - - - - Redis Search is a query and indexing engine for Redis, providing secondary indexing, full-text search and aggregations capabilities. - -- We have to create index on schema to be able to search on its data - -```sh -# syntax -FT.CREATE {index_name} ON JSON SCHEMA {json_path} AS {attribute} {type} -# note : attribute = logical name, json_path = JSONPath expressions - -# example -FT.CREATE userIdx ON JSON SCHEMA $.user.name AS name TEXT $.user.hobbies AS hobbies TAG $.user.age as age NUMERIC -# note : Can search by any attribute mentioned in the above index. -``` - -- More details on Indexing JSON can be found [here](https://redis.io/docs/stack/search/indexing_json/) - -Once index is created, any pre-existing/ new/ modified JSON document is automatically indexed. - -```json -//sample json document -{ - "user": { - "name": "John Smith", - "hobbies": "foo,bar", - "age": 23 - } -} -``` - -```sh -# adding JSON document -JSON.SET myDoc $ '{"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}' -``` - -- Search - -```sh -# search all user documents with name 'John' -FT.SEARCH userIdx '@name:(John)' - -# output -1) (integer) 1 -2) "myDoc" -3) 1) "$" - 2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}" -``` - -- Search & project required fields - -```sh -# search documents with name 'John' & project only age field -FT.SEARCH userIdx '@name:(John)' RETURN 1 $.user.age - -# output -1) (integer) 1 -2) "myDoc" -3) 1) "$.user.age" - 2) "23" -``` - -```sh -# project multiple fields -FT.SEARCH userIdx '@name:(John)' RETURN 2 $.user.age $.user.name - -# output -1) (integer) 1 -2) "myDoc" -3) 1) "$.user.age" - 2) "23" - 3) "$.user.name" - 4) "John Smith" - -#------------ -# project with alias name -FT.SEARCH userIdx '@name:(John)' RETURN 3 $.user.age AS userAge - -1) (integer) 1 -2) "myDoc" -3) 1) "userAge" - 2) "23" -#------------ - -# multi field query -FT.SEARCH userIdx '@name:(John) @hobbies:{foo | me} @age:[20 30]' - -# output -1) (integer) 1 -2) "myDoc" -3) 1) "$" - 2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}" -``` - -More details on [query syntax](https://redis.io/docs/stack/search/reference/query_syntax/) - -- Drop index - -```sh -FT.DROPINDEX userIdx -``` - -Watch video [RediSearch (RedisConf 2020)](https://www.youtube.com/watch?v=9R29LLWquME), also more details can be found in [docs](https://redis.io/docs/stack/search/) - - - - -A graph database as a Redis module - -TODO : to be read & written - - - - -Time Series data structure for Redis - -TODO : to be read & written - - - - - -Dynamic execution framework for your Redis data - -TODO : to be written - - - - - -Probabilistic Datatypes Module for Redis - -TODO : to be read & written - - - - - -## Redis OM - -Redis OM is a client library to work with Redis **easily**. -It allows you to model redis data , save & search json data ..etc - - - - - -```sh -# install RedisOM in the project -npm install redis-om --save -``` - -- create RedisOM Client & connect to redis - -```js -//client.js file - -import { Client } from 'redis-om'; - -// pulls the Redis URL from .env -const url = process.env.REDIS_URL; - -const client = new Client(); -await client.open(url); - -export default client; -``` - -- Create Entity, Schema & Repository - -```js -//person.js file - -import { Entity, Schema } from 'redis-om'; -import client from './client.js'; - -class Person extends Entity {} - -const personSchema = new Schema(Person, { - firstName: { type: 'string' }, - lastName: { type: 'string' }, - age: { type: 'number' }, - verified: { type: 'boolean' }, - location: { type: 'point' }, - locationUpdated: { type: 'date' }, - skills: { type: 'string[]' }, - personalStatement: { type: 'text' }, -}); - -export const personRepository = client.fetchRepository(personSchema); - -//creating index to make person schema searchable -await personRepository.createIndex(); -``` - -```js -import { Router } from 'express'; -import { personRepository } from 'person.js'; -``` - -- Insert sample - -```js -let input = { - firstName: 'Rupert', - lastName: 'Holmes', - age: 75, - verified: false, - location: { - longitude: 45.678, - latitude: 45.678, - }, - locationUpdated: '2022-03-01T12:34:56.123Z', - skills: ['singing', 'songwriting', 'playwriting'], - personalStatement: 'I like piña coladas and walks in the rain', -}; -const person = await personRepository.createAndSave(input); -``` - -- Read sample - -```js -const id = '01FX8N39YVZRCQNAW0R5T53H5T'; -const person = await personRepository.fetch(id); -``` - -- Update sample - -```js -const person = await personRepository.fetch(req.params.id); - -person.firstName = 'Alex'; - -//null to remove that field -person.lastName = null; - -await personRepository.save(person); -``` - -- Update location sample - -```js -const id = '01G79HZ6P3WYWFTY36JF6H3529'; -const longitude = Number('45.678'); -const latitude = 45.678; -const locationUpdated = new Date(); - -const person = await personRepository.fetch(id); -person.location = { longitude, latitude }; -person.locationUpdated = locationUpdated; -await personRepository.save(person); -``` - -- Delete sample - -```js -await personRepository.remove(req.params.id); -``` - -- Search samples - -```js -//get all records of persons -const queryBuilder = personRepository.search(); -const persons = await queryBuilder.return.all(); - -//"multiple and" condition sample -const queryBuilder = personRepository - .search() - .where('verified') - .eq(true) // == - .and('age') - .gte(21) // >= - .and('lastName') - .eq(lastName); -//console.log(queryBuilder.query); -const persons = await queryBuilder.return.all(); - -// "OR" condition sample -const queryBuilder = personRepository - .search() - .where('verified') - .eq(true) - .or((search) => search.where('age').gte(21).and('lastName').eq(lastName)) - .sortAscending('age'); -const persons = await queryBuilder.return.all(); -``` - -Useful links : [Github repo](https://github.com/redis/redis-om-node) and [getting started docs](https://redis.io/docs/stack/get-started/tutorials/stack-node/), -[getting started video](https://www.youtube.com/watch?v=KUfufrwpBkM) and it's [source code](https://github.com/redis-developer/express-redis-om-workshop) - - - - -- Join the [community](/community/) - -
diff --git a/docs/howtos/quick-start/index-quick-start.mdx b/docs/howtos/quick-start/index-quick-start.mdx index 2dbbc57da36..f852137daad 100644 --- a/docs/howtos/quick-start/index-quick-start.mdx +++ b/docs/howtos/quick-start/index-quick-start.mdx @@ -3,7 +3,7 @@ id: index-quick-start title: Quick Start sidebar_label: Quick Start slug: /howtos/quick-start -authors: [prasan] +authors: [prasan,will] --- import Tabs from '@theme/Tabs'; @@ -48,6 +48,7 @@ Use one of the following ways to set up Redis : @@ -98,25 +100,28 @@ Use one of the following ways to set up Redis : - + - - - - - + + + + + + + + @@ -124,12 +129,13 @@ Use one of the following ways to set up Redis : @@ -138,27 +144,27 @@ Use one of the following ways to set up Redis : - + - + - + - + - + - + diff --git a/docs/howtos/quick-start/node/_node-basic-querying.mdx b/docs/howtos/quick-start/node/_node-basic-querying.mdx index fab91a9b4a2..c0c7b9fe75c 100644 --- a/docs/howtos/quick-start/node/_node-basic-querying.mdx +++ b/docs/howtos/quick-start/node/_node-basic-querying.mdx @@ -84,4 +84,4 @@ await client.quit(); await client.disconnect(); ``` -- More details at [Github repo](https://github.com/redis/node-redis) and also check Javascript/ NodeJS apps at [Redis Launchpad](https://launchpad.redis.com/) +- For more information visit the [node-redis Github repo](https://github.com/redis/node-redis), and also check JavaScript/NodeJS apps at [Redis Launchpad](https://launchpad.redis.com/) diff --git a/docs/howtos/quick-start/node/_node-secondary-indexing.mdx b/docs/howtos/quick-start/node/_node-secondary-indexing.mdx index 35aa613fb22..32613e9aeb1 100644 --- a/docs/howtos/quick-start/node/_node-secondary-indexing.mdx +++ b/docs/howtos/quick-start/node/_node-secondary-indexing.mdx @@ -1,5 +1,5 @@ -[Redis OM Node](https://github.com/redis/redis-om-node) client library is used in below example but you can also use [Node Redis](https://github.com/redis/node-redis), [IO Redis](https://github.com/luin/ioredis) or any other supported [client](https://redis.io/resources/clients/) +The following example uses [Redis OM Node](https://github.com/redis/redis-om-node), but you can also use [Node Redis](https://github.com/redis/node-redis), [IO Redis](https://github.com/luin/ioredis) or any other supported [client](https://redis.io/resources/clients/) ```sh # install RedisOM in the project @@ -54,7 +54,7 @@ import { Router } from 'express'; import { personRepository } from 'person.js'; ``` -- Insert sample +- Insert example ```js let input = { @@ -73,14 +73,14 @@ let input = { const person = await personRepository.createAndSave(input); ``` -- Read sample +- Read example ```js const id = '01FX8N39YVZRCQNAW0R5T53H5T'; const person = await personRepository.fetch(id); ``` -- Update sample +- Update example ```js const person = await personRepository.fetch(req.params.id); @@ -107,20 +107,14 @@ person.locationUpdated = locationUpdated; await personRepository.save(person); ``` -- Delete sample +- Search examples ```js -await personRepository.remove(req.params.id); -``` - -- Search samples - -```js -//get all records of persons +// Get all person records const queryBuilder = personRepository.search(); -const persons = await queryBuilder.return.all(); +const people = await queryBuilder.return.all(); -//"multiple and" condition sample +// Multiple AND conditions example const queryBuilder = personRepository .search() .where('verified') @@ -130,17 +124,27 @@ const queryBuilder = personRepository .and('lastName') .eq(lastName); //console.log(queryBuilder.query); -const persons = await queryBuilder.return.all(); +const people = await queryBuilder.return.all(); -// "OR" condition sample +// Multiple OR conditions example const queryBuilder = personRepository .search() .where('verified') .eq(true) .or((search) => search.where('age').gte(21).and('lastName').eq(lastName)) .sortAscending('age'); -const persons = await queryBuilder.return.all(); +const people = await queryBuilder.return.all(); ``` -Useful links : [Github repo](https://github.com/redis/redis-om-node) and [getting started docs](https://redis.io/docs/stack/get-started/tutorials/stack-node/), -[getting started video](https://www.youtube.com/watch?v=KUfufrwpBkM) and it's [source code](https://github.com/redis-developer/express-redis-om-workshop) +- Delete example + +```js +await personRepository.remove(req.params.id); +``` + +### Useful Resources + +1. [Github repo](https://github.com/redis/redis-om-node) +1. [Getting started docs](https://redis.io/docs/stack/get-started/tutorials/stack-node/) +1. [Getting started video](https://www.youtube.com/watch?v=KUfufrwpBkM) + - [Source code](https://github.com/redis-developer/express-redis-om-workshop) diff --git a/docs/howtos/quick-start/python/_python-basic-querying.mdx b/docs/howtos/quick-start/python/_python-basic-querying.mdx index 06f59090d94..682f186cb35 100644 --- a/docs/howtos/quick-start/python/_python-basic-querying.mdx +++ b/docs/howtos/quick-start/python/_python-basic-querying.mdx @@ -60,3 +60,5 @@ r.decr('key') # use below style for unsupported commands by client library r.execute_command('SET', 'key', 'value') ``` + +- For more information, checkout the [redis-py Github repo](https://github.com/redis/redis-py) diff --git a/docs/howtos/quick-start/python/_python-secondary-indexing.mdx b/docs/howtos/quick-start/python/_python-secondary-indexing.mdx index 6a7477428c7..fcf5c21befa 100644 --- a/docs/howtos/quick-start/python/_python-secondary-indexing.mdx +++ b/docs/howtos/quick-start/python/_python-secondary-indexing.mdx @@ -1,3 +1,4 @@ +The following example uses [Redis OM Python](https://github.com/redis/redis-om-python), but you can also use [redis-py](https://github.com/redis/redis-py) or any other supported [client](https://redis.io/resources/clients/) ```sh # install Redis OM in the project @@ -8,7 +9,8 @@ Create an embedded JSON model ```python import datetime -from typing import Optional +import dateutil.parser +from typing import List, Optional from redis_om import ( EmbeddedJsonModel, @@ -17,38 +19,111 @@ from redis_om import ( Migrator, ) +class Point(EmbeddedJsonModel): + longitude: float = Field(index=True) + latitude: float = Field(index=True) -class Address(EmbeddedJsonModel): - address_line_1: str - address_line_2: Optional[str] - city: str = Field(index=True) - state: str = Field(index=True) - country: str - postal_code: str = Field(index=True) - -class Customer(JsonModel): +class Person(JsonModel): first_name: str = Field(index=True) - last_name: str = Field(index=True) - email: str = Field(index=True) - join_date: datetime.date + last_name: Optional[str] = Field(index=True) age: int = Field(index=True) - bio: Optional[str] = Field(index=True, full_text_search=True, - default="") - - # Creates an embedded model. - address: Address - + verified: bool + location: Point + location_updated: datetime.datetime = Field(index=True) + skills: List[str] + personal_statement: str = Field(index=True, full_text_search=True) -# With these two models and a Redis deployment with the RedisJSON -# module installed, we can run queries like the following. # Before running queries, we need to run migrations to set up the # indexes that Redis OM will use. You can also use the `migrate` # CLI tool for this! Migrator().run() +``` + +- Insert example + +```pythong +person = Person(**{ + "first_name": "Rupert", + "last_name": "Holmes", + "age": 75, + "verified": False, + "location": { + "longitude": 45.678, + "latitude": 45.678 + }, + "location_updated": dateutil.parser.isoparse("2022-03-01T12:34:56.123Z"), + "skills": ["singing", "songwriting", "playwriting"], + "personal_statement": "I like piña coladas and walks in the rain" +}).save() +``` + +- Read example + +```python +id = person.pk +person = Person.get(id) +``` + +- Update example + +```python +person = Person.get(id) +person.first_name = "Alex" +person.last_name = None +person.save() +``` + +- Update embedded JSON example + +```python +person = Person.get(id) +person.location = Point(longitude=44.678, latitude=44.678) +person.location_updated = datetime.datetime.now() +person.save() +``` + +- Search examples + +```python +# Get all Person records + +all = Person.find().all() + +# Multiple AND conditions example + +people = Person.find( + (Person.age > 21) & + (Person.first_name == "Alex") +).all() + +# Multiple OR conditions example + +people = Person.find( + (Person.age > 75) | + (Person.first_name == "Alex") +).all() + +# Multiple AND + OR conditions example + +people = Person.find( + ((Person.age > 21) & + (Person.first_name == "Alex")) & + ((Person.age > 75) | + (Person.first_name == "Alex")) +).all() +``` + +- Delete example + +```pythong +Person.get(id).delete() +``` + +### Useful Resources -# Find all customers who live in San Antonio, TX -Customer.find(Customer.address.city == "San Antonio", - Customer.address.state == "TX") -``` \ No newline at end of file +1. [Github repo](https://github.com/redis/redis-om-python) +1. [Getting started docs](https://redis.io/docs/stack/get-started/tutorials/stack-python/) +1. [Getting started video](https://www.youtube.com/watch?v=PPT1FElAS84) + - [Source code](https://github.com/redis-developer/redis-om-python-flask-skeleton-app) diff --git a/sidebars.js b/sidebars.js index 9b902642a48..84dc48f7789 100644 --- a/sidebars.js +++ b/sidebars.js @@ -5,6 +5,11 @@ module.exports = { label: 'Home', href: '/', }, + { + type: 'doc', + label: 'Quick Start', + id: 'howtos/quick-start/index-quick-start', + }, { type: 'category', label: 'Create', @@ -451,7 +456,6 @@ module.exports = { label: 'HowTos & Tutorials', items: [ 'howtos/index-howtos', - // 'howtos/quick-start/index-quick-start', 'howtos/redisearch/index-redisearch', { type: 'category', From 05aec27b7778205d8a37cb10e229f0db4da1d003 Mon Sep 17 00:00:00 2001 From: William Johnston Date: Thu, 29 Dec 2022 13:19:26 -0800 Subject: [PATCH 06/16] nodejs quick start code is now a continuous example --- .../node/_node-secondary-indexing.mdx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/howtos/quick-start/node/_node-secondary-indexing.mdx b/docs/howtos/quick-start/node/_node-secondary-indexing.mdx index 32613e9aeb1..dc51be7cf8a 100644 --- a/docs/howtos/quick-start/node/_node-secondary-indexing.mdx +++ b/docs/howtos/quick-start/node/_node-secondary-indexing.mdx @@ -1,5 +1,5 @@ -The following example uses [Redis OM Node](https://github.com/redis/redis-om-node), but you can also use [Node Redis](https://github.com/redis/node-redis), [IO Redis](https://github.com/luin/ioredis) or any other supported [client](https://redis.io/resources/clients/) +The following example uses [Redis OM Node](https://github.com/redis/redis-om-node), but you can also use [Node Redis](https://github.com/redis/node-redis), [IO Redis](https://github.com/luin/ioredis), or any other supported [client](https://redis.io/resources/clients/) ```sh # install RedisOM in the project @@ -57,7 +57,7 @@ import { personRepository } from 'person.js'; - Insert example ```js -let input = { +const input = { firstName: 'Rupert', lastName: 'Holmes', age: 75, @@ -70,20 +70,20 @@ let input = { skills: ['singing', 'songwriting', 'playwriting'], personalStatement: 'I like piña coladas and walks in the rain', }; -const person = await personRepository.createAndSave(input); +let person = await personRepository.createAndSave(input); ``` - Read example ```js -const id = '01FX8N39YVZRCQNAW0R5T53H5T'; -const person = await personRepository.fetch(id); +const id = person.entityId; +person = await personRepository.fetch(id); ``` - Update example ```js -const person = await personRepository.fetch(req.params.id); +person = await personRepository.fetch(id); person.firstName = 'Alex'; @@ -96,8 +96,7 @@ await personRepository.save(person); - Update location sample ```js -const id = '01G79HZ6P3WYWFTY36JF6H3529'; -const longitude = Number('45.678'); +const longitude = 45.678; const latitude = 45.678; const locationUpdated = new Date(); @@ -139,7 +138,7 @@ const people = await queryBuilder.return.all(); - Delete example ```js -await personRepository.remove(req.params.id); +await personRepository.remove(id); ``` ### Useful Resources From aea0bf178d0433981c1192e8589fc61bac1502fe Mon Sep 17 00:00:00 2001 From: William Johnston Date: Thu, 29 Dec 2022 13:21:49 -0800 Subject: [PATCH 07/16] hiding java and c# until they are complete --- docs/howtos/quick-start/index-quick-start.mdx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/howtos/quick-start/index-quick-start.mdx b/docs/howtos/quick-start/index-quick-start.mdx index f852137daad..5167213d992 100644 --- a/docs/howtos/quick-start/index-quick-start.mdx +++ b/docs/howtos/quick-start/index-quick-start.mdx @@ -90,8 +90,8 @@ Use one of the following ways to set up Redis : {label: 'CLI', value: 'CLI'}, {label: 'JavaScript/Node.js', value: 'JS'}, {label: 'Python', value: 'PYTHON'}, - {label: 'C#', value: 'C#'}, - {label: 'Java', value: 'JAVA'}, + //{label: 'C#', value: 'C#'}, + //{label: 'Java', value: 'JAVA'}, ]}> @@ -112,7 +112,7 @@ Use one of the following ways to set up Redis : - + ## Secondary indexing & searching JSON @@ -134,8 +134,8 @@ Use one of the following ways to set up Redis : {label: 'CLI', value: 'CLI'}, {label: 'JavaScript/Node.js', value: 'JS'}, {label: 'Python', value: 'PYTHON'}, - {label: 'C#', value: 'C#'}, - {label: 'Java', value: 'JAVA'}, + //{label: 'C#', value: 'C#'}, + //{label: 'Java', value: 'JAVA'}, ]}> @@ -156,7 +156,7 @@ Use one of the following ways to set up Redis : - + ## Sync with other databases From 3d19fe2356e77a8317c4c71658e52322712d9b6e Mon Sep 17 00:00:00 2001 From: William Johnston Date: Thu, 29 Dec 2022 14:41:26 -0800 Subject: [PATCH 08/16] adjusting headers and language --- docs/howtos/quick-start/index-quick-start.mdx | 86 +++++++++++-------- .../quick-start/setup/_docker-setup.mdx | 6 +- .../howtos/quick-start/setup/_linux-setup.mdx | 37 +++++++- .../quick-start/setup/_windows-setup.mdx | 21 +---- 4 files changed, 87 insertions(+), 63 deletions(-) diff --git a/docs/howtos/quick-start/index-quick-start.mdx b/docs/howtos/quick-start/index-quick-start.mdx index 5167213d992..297823bbf13 100644 --- a/docs/howtos/quick-start/index-quick-start.mdx +++ b/docs/howtos/quick-start/index-quick-start.mdx @@ -1,7 +1,7 @@ --- id: index-quick-start -title: Quick Start -sidebar_label: Quick Start +title: Getting Started +sidebar_label: Getting Started slug: /howtos/quick-start authors: [prasan,will] --- @@ -25,11 +25,9 @@ import NodeSecondaryIndexing from './node/_node-secondary-indexing.mdx'; import PythonBasicQuerying from './python/_python-basic-querying.mdx'; import PythonSecondaryIndexing from './python/_python-secondary-indexing.mdx'; - import JavaBasicQuerying from './java/_java-basic-querying.mdx'; import JavaSecondaryIndexing from './java/_java-secondary-indexing.mdx'; - import CSharpBasicQuerying from './csharp/_csharp-basic-querying.mdx'; import CSharpSecondaryIndexing from './csharp/_csharp-secondary-indexing.mdx'; @@ -37,28 +35,37 @@ import CSharpSecondaryIndexing from './csharp/_csharp-secondary-indexing.mdx';
+Welcome to the getting started for the official Redis Developer Hub! + +If you are new to Redis, we recommend starting with [Redis University (RU101)](https://university.redis.com/courses/ru101/). RU101 is an introductory course, perfect for developers new to Redis. In this course, you’ll learn about the data structures in Redis, and you’ll see how to practically apply them in the real world. + +If you have questions related to Redis, come join the [Redis Discord server](https://discord.gg/redis). Our Discord server is a place where you can learn, share, and collaborate about anything and everything Redis. Connect with users from the community and Redis University. Get your questions answered and learn cool new tips and tricks! Watch for notifications of the latest content from Redis and the community. And share your own content with the community. + ## Setup Redis -Use one of the following ways to set up Redis : +There are essentially two ways you can use Redis: + +- **Cloud Redis**: A hosted and serverless Redis database-as-a-service (DBaaS). The fastest way to deploy Redis Enterprise via Amazon AWS, Google Cloud Platform, or Microsoft Azure. + - [Getting Started](/create/rediscloud) + - [Videos](https://www.youtube.com/playlist?list=PL83Wfqi-zYZG6uGxBagsbqjpsi2XBEj1K), + - [Free Sign-up](https://redis.com/try-free) +- **On-prem/local Redis**: Self-managed Redis using your own server and any operating system (Mac OS, Windows, or Linux). -- **Cloud** : Hosted and serverless database-as-a-service (DBaaS). The fastest way to deploy Redis Enterprise via Amazon AWS, Google Cloud Platform or Microsoft Azure. - - [Getting Started](/create/rediscloud), [Videos](https://www.youtube.com/playlist?list=PL83Wfqi-zYZG6uGxBagsbqjpsi2XBEj1K), - [Free Signup](https://app.redislabs.com/#/login) -- **OnPrem/ Desktop** : A self-managed data platform that unlocks the full potential of Redis at enterprise scale on various operating systems like Mac OS, Windows or Linux. +If you choose to use local Redis we strongly recommend using Docker. If you choose not to use Docker, use the following instructions based on your OS: - + - + @@ -67,21 +74,22 @@ Use one of the following ways to set up Redis : - - + + + - + - + -## Basic Querying +## Basic Querying with Redis --> -## Secondary indexing & searching JSON +## Secondary Indexing and Searching with Redis --> -## Sync with other databases +## Sync Redis with Other Databases -RedisGears adds dynamic execution framework for your Redis data. +RedisGears adds a dynamic execution framework for your Redis data that enables you to write and execute functions that implement data flows in Redis. Consider following example to sync data with MongoDB. - Create the below python file and update the MongoDB connection details, database, collection and primary key name to be synced -```python -# movies-write-behind.py - +```python title="write-behind.py" # Gears Recipe for a single write behind # import redis gears & mongo db libs @@ -209,26 +215,32 @@ ENV_COLLECTION1_PRIMARY_KEY=movieId ENV_COLLECTION1_PREFIX_KEY=movie ``` -Above code shows keys starting with "movie" in Redis will be synced with "movies" collection of MongoDB +The code above demonstrates how you would sync a "movies" collection in MongoDB with Redis using the "movie" key prefix. -- Created python file must be loaded in redis server +To get this working you first need to load the python file into redis-server: ```sh -redis-cli rg.pyexecute "`cat movies-write-behind.py`" REQUIREMENTS rgsync pymongo==3.12.0 +redis-cli rg.pyexecute "`cat write-behind.py`" REQUIREMENTS rgsync pymongo==3.12.0 ``` -Now insert a json item in to redis starting with the prefix specified in the python file +Now, insert a JSON item in to Redis starting with the prefix specified in the python file (i.e. "movie"): ```sh -# redis cli command +# redis-cli command > JSON.SET movie:123 $ '{"movieId":123,"name":"RRR","isActive": true}' ``` -- Now, verify whether the json is inserted in MongoDB +Now, verify whether the JSON is inserted into MongoDB. + +### Additional Resources For Syncing with Redis and Other Databases -More resources at [Redis gear sync with MongoDB](https://github.com/RedisGears/rgsync/tree/master/examples/mongo),[RG.PYEXECUTE](https://oss.redis.com/redisgears/commands.html#rgpyexecute),[rgsync](https://github.com/RedisGears/rgsync#running-the-recipe),[gears-cli](https://github.com/RedisGears/gears-cli), [RedisGears dynamic script](/howtos/redisgears) +1. [Redis gear sync with MongoDB](https://github.com/RedisGears/rgsync/tree/master/examples/mongo) +1. [RG.PYEXECUTE](https://oss.redis.com/redisgears/commands.html#rgpyexecute) +1. [rgsync](https://github.com/RedisGears/rgsync#running-the-recipe) +1. [gears-cli](https://github.com/RedisGears/gears-cli) +1. [RedisGears dynamic script](/howtos/redisgears) -## Probabilistic queries +## Probabilistic Data and Queries with Redis Redis bloom adds probabilistic Datatypes Module for Redis. @@ -236,7 +248,7 @@ Redis bloom adds probabilistic Datatypes Module for Redis. More details in [docs](https://redis.io/docs/stack/bloom/) -## Graph queries +## Graph Data and Queries with Redis RedisGraph is a graph database built on Redis. @@ -244,7 +256,7 @@ RedisGraph is a graph database built on Redis. More details in [docs](https://redis.io/docs/stack/graph/) -## Timeseries queries +## TimeSeries Data and Queries with Redis RedisTimeSeries is used to ingest and query time series data with Redis @@ -252,7 +264,7 @@ RedisTimeSeries is used to ingest and query time series data with Redis More details in [docs](https://redis.io/docs/stack/timeseries/) -## Links +## Additional Resources - Join the [community](/community/) - [RedisInsight](https://redis.com/redis-enterprise/redis-insight/) diff --git a/docs/howtos/quick-start/setup/_docker-setup.mdx b/docs/howtos/quick-start/setup/_docker-setup.mdx index 3a8fd91699d..93fb23f755a 100644 --- a/docs/howtos/quick-start/setup/_docker-setup.mdx +++ b/docs/howtos/quick-start/setup/_docker-setup.mdx @@ -1,14 +1,12 @@ -Below docker run command exposes RedisServer on 6379 and RedisInsight on port 8001. -You can use RedisInsight by pointing your browser to localhost:8001. +The `docker run` command below exposes redis-server on port 6379 and RedisInsight on port 8001. You can use RedisInsight by pointing your browser to http://localhost:8001. ```sh # install docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest ``` -You can use redis-cli to connect to the server. -If you don’t have redis-cli installed locally, you can run it from the Docker container like below: +You can use `redis-cli` to connect to the server at localhost:6379. If you don’t have `redis-cli` installed locally, you can run it from the Docker container like below: ```sh # connect diff --git a/docs/howtos/quick-start/setup/_linux-setup.mdx b/docs/howtos/quick-start/setup/_linux-setup.mdx index 7a696a21571..1220fd95e75 100644 --- a/docs/howtos/quick-start/setup/_linux-setup.mdx +++ b/docs/howtos/quick-start/setup/_linux-setup.mdx @@ -1,5 +1,8 @@ -- **Ubuntu** (16.04, 18.04, 20.04) + +### Using APT with Ubuntu/Debian + +Works with Ubuntu 16.04, 18.04, or 20.04 and Debian 11 ```sh curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg @@ -8,9 +11,11 @@ sudo apt-get update sudo apt-get install redis-stack-server ``` -- **RHEL/ CentOS** (7, 8) +### From the official RPM Feed + +Works with RHEL7/CentOS7 or RHEL8/CentOS8 -Create the file /etc/yum.repos.d/redis.repo with the following contents +Create the file /etc/yum.repos.d/redis.repo with the following contents: ``` [Redis] @@ -27,4 +32,30 @@ sudo yum install epel-release sudo yum install redis-stack-server ``` +### With snap + +Download the [latest Redis Stack snap package](https://redis.io/download/#redis-stack-downloads). + +To install, run: + +```sh +sudo snap install --dangerous --classic +``` + +### With AppImage + +Download the [latest Redis Stack AppImage package](https://redis.io/download/#redis-stack-downloads). + +To enable the install, run: + +```sh +chmod a+x +``` + +To install run: + +```sh +./ +``` + Detailed Linux instructions can be viewed [here](/create/linux/) diff --git a/docs/howtos/quick-start/setup/_windows-setup.mdx b/docs/howtos/quick-start/setup/_windows-setup.mdx index c3b4fc145b8..151dcc031ac 100644 --- a/docs/howtos/quick-start/setup/_windows-setup.mdx +++ b/docs/howtos/quick-start/setup/_windows-setup.mdx @@ -1,21 +1,4 @@ -Redis is not officially supported on Windows, but can be installed via WSL2 (Windows Subsystem for Linux) for development purpose +Redis is not officially supported on Windows, so we recommend using Docker. -- Enable [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install) to run Ubuntu on Windows and follow below Ubuntu steps - -```sh - sudo apt-add-repository ppa:redislabs/redis - sudo apt-get update - sudo apt-get upgrade - sudo apt-get install redis-server -``` - -``` -# Restart the Redis server -sudo service redis-server restart - -# Connect to Redis -redis-cli -``` - -Detailed Windows instructions can be viewed [here](/create/windows) +Please follow the Docker instructions. From a4624e84c1b18692e94a97e55dee6a5b6729a33e Mon Sep 17 00:00:00 2001 From: William Johnston Date: Thu, 29 Dec 2022 14:50:57 -0800 Subject: [PATCH 09/16] longer, non-image module examples --- docs/howtos/quick-start/index-quick-start.mdx | 97 +++++++++++++++++-- 1 file changed, 90 insertions(+), 7 deletions(-) diff --git a/docs/howtos/quick-start/index-quick-start.mdx b/docs/howtos/quick-start/index-quick-start.mdx index 297823bbf13..9de015c3673 100644 --- a/docs/howtos/quick-start/index-quick-start.mdx +++ b/docs/howtos/quick-start/index-quick-start.mdx @@ -242,25 +242,108 @@ Now, verify whether the JSON is inserted into MongoDB. ## Probabilistic Data and Queries with Redis -Redis bloom adds probabilistic Datatypes Module for Redis. +Redis Stack supports probabilistic datatypes and queries. Below you will find a stock leaderboard example: -![RedisBloom](./images/redis-bloom.svg) +```sh +# Reserve a new leaderboard filter +> TOPK.RESERVE trending-stocks 12 50 4 0.9 +"OK" + +# Add a new entries to the leaderboard +> TOPK.ADD trending-stocks AAPL AMD MSFT INTC GOOG FB NFLX GME AMC TSLA +1) "null" ... + +# Get the leaderboard +> TOPK.LIST trending-stocks +1) "AAPL" +2) "AMD" +2) "MSFT" ... + +# Get information about the leaderboard +> TOPK.INFO trending-stocks +1) "k" +2) "12" +3) "width" +4) "50" +5) "depth" +6) "4" +7) "decay" +8) "0.90000000000000002" +``` More details in [docs](https://redis.io/docs/stack/bloom/) ## Graph Data and Queries with Redis -RedisGraph is a graph database built on Redis. - -![RedisGraph](./images/redis-graph.svg) +Redis Stack is a NoSQL graph database that translates Cypher queries to matrix operations executed over a GraphBLAS engine. It's useful for social graph operation, fraud detection, and real-time recommendation engines. Below you will find an org chart graph example: + +```shell +# Create any graph, for example an Org Chart +> GRAPH.QUERY OrgChart "CREATE (:Employee {name:'Doug'}), (:Employee {name:'Dani'})-[:REPORTS_TO]->(:Employee {name:'Doug'}), (:Employee {name:'Otto'})-[:REPORTS_TO]->(:Employee {name:'Doug'})" +1) 1) "Labels added: 1" + 2) "Nodes created: 5" + 3) "Properties set: 5" + 4) "Relationships created: 2" + 5) "Cached execution: 0" + 6) "Query internal execution time: 0.324600 milliseconds" + +# Get a list of employees and who they report to +> GRAPH.QUERY OrgChart "MATCH (e:Employee)-[:REPORTS_TO]->(m:Employee) RETURN e.name, m.name" +1) 1) "e.name" + 2) "m.name" +2) 1) 1) "Dani" + 2) "Doug" + 2) 1) "Otto" + 2) "Doug" +3) 1) "Cached execution: 0" + 2) "Query internal execution time: 0.288619 milliseconds" + +# Get a count of how many reports Doug has +> GRAPH.QUERY OrgChart "MATCH (e:Employee)-[:REPORTS_TO]->(m:Employee {name: 'Doug'}) RETURN COUNT(e.name)" +1) 1) "COUNT(e.name)" +2) 1) 1) "2" +3) 1) "Cached execution: 0" + 2) "Query internal execution time: 0.340888 milliseconds" +``` More details in [docs](https://redis.io/docs/stack/graph/) ## TimeSeries Data and Queries with Redis -RedisTimeSeries is used to ingest and query time series data with Redis +Redis Stack supports time-series use cases such as IoT, stock prices, and telemetry. You can ingest and query millions of samples and events at the speed of Redis. You can also use a variety of queries for visualization and monitoring with built-in connectors to popular tools like Grafana, Prometheus, and Telegraf. + +The following example demonstrates how you might store temperature sensor readings in Redis Stack: + +```shell +# Create new time-series, for example temperature readings +> TS.CREATE temperature:raw DUPLICATE_POLICY LAST +"OK" -![RedisTimeSeries](./images/redis-timeseries.svg) +# Create a bucket for monthly aggregation +> TS.CREATE temperature:monthly DUPLICATE_POLICY LAST +"OK" + +# Automatically aggregate based on time-weighted average +> TS.CREATERULE temperature:raw temperature:monthly AGGREGATION twa 2629800000 +"OK" + +# Add data to the raw time-series +> TS.MADD temperature:raw 1621666800000 52 ... +1) "1621666800000" ... + +# View the monthly time-weighted average temperatures +> TS.RANGE temperature:monthly 0 + +1) 1) "1621666800000" + 2) "52" ... + +# Delete compaction rule +> TS.DELETERULE temperature:raw temperature:monthly +"OK" + +# Delete partial time-series +> TS.DEL temperature:raw 0 1621666800000 +(integer) 1 +``` More details in [docs](https://redis.io/docs/stack/timeseries/) From 873ed3de1223c1a96e856a79ce5e51bb5cdc4631 Mon Sep 17 00:00:00 2001 From: William Johnston Date: Thu, 29 Dec 2022 14:58:53 -0800 Subject: [PATCH 10/16] more language cleanup, sh -> shell --- .../quick-start/cli/_cli-basic-querying.mdx | 54 ++++++------- .../cli/_cli-secondary-indexing.mdx | 78 +++++++++---------- docs/howtos/quick-start/index-quick-start.mdx | 8 +- .../quick-start/node/_node-basic-querying.mdx | 2 +- .../node/_node-secondary-indexing.mdx | 2 +- .../python/_python-basic-querying.mdx | 2 +- .../python/_python-secondary-indexing.mdx | 2 +- .../quick-start/setup/_docker-setup.mdx | 8 +- .../howtos/quick-start/setup/_linux-setup.mdx | 16 ++-- .../howtos/quick-start/setup/_macos-setup.mdx | 8 +- 10 files changed, 86 insertions(+), 94 deletions(-) diff --git a/docs/howtos/quick-start/cli/_cli-basic-querying.mdx b/docs/howtos/quick-start/cli/_cli-basic-querying.mdx index 29fcb0f1759..1119d363c0a 100644 --- a/docs/howtos/quick-start/cli/_cli-basic-querying.mdx +++ b/docs/howtos/quick-start/cli/_cli-basic-querying.mdx @@ -4,96 +4,96 @@ **RedisInsight** ![RedisInsight](../images/redis-insight.svg) -```sh +```shell # syntax 1 : connect using host & port -redis-cli -h host -p port -a password +$ redis-cli -h host -p port -a password # example 1 -redis-cli -h redis15.localnet.org -p 6390 -a myUnguessablePassword +$ redis-cli -h redis15.localnet.org -p 6390 -a myUnguessablePassword # syntax 2 : connect using uri -redis-cli -u redis://user:password@host:port/dbnum +$ redis-cli -u redis://user:password@host:port/dbnum # example 2 -redis-cli -u redis://LJenkins:p%40ssw0rd@redis-16379.hosted.com:16379/0 +$ redis-cli -u redis://LJenkins:p%40ssw0rd@redis-16379.hosted.com:16379/0 ``` - Basic CLI / RedisInsight workbench commands -```sh +```shell # syntax : Check specific keys -keys pattern +> keys pattern # example -keys * +> keys * #------------ # syntax : Check number of keys in database -dbsize +> dbsize #------------ # syntax : set a key value -set key value EX expirySeconds +> set key value EX expirySeconds # example -set company redis EX 60 +> set company redis EX 60 #------------ # syntax : get value by key -get key +> get key # example -get company +> get company #------------ # syntax : delete keys -del key1 key2 key3 ... keyN +> del key1 key2 key3 ... keyN # example -del company +> del company #------------ # syntax : Check if key exists -exists key1 +> exists key1 # example -exists company +> exists company #------------ # syntax : set expiry to key -expire key seconds +> expire key seconds # example -expire lastname 60 +> expire lastname 60 #------------ # syntax : remove expiry from key -persist key +> persist key # example -persist lastname +> persist lastname #------------ # syntax : find (remaining) time to live of a key -ttl key +> ttl key # example -ttl lastname +> ttl lastname #------------ # syntax : increment a number -incr key +> incr key # example -incr counter +> incr counter #------------ # syntax : decrement a number -decr key +> decr key # example -decr counter +> decr counter ``` Detailed CLI instructions can be viewed [here](https://redis.io/docs/manual/cli/) and diff --git a/docs/howtos/quick-start/cli/_cli-secondary-indexing.mdx b/docs/howtos/quick-start/cli/_cli-secondary-indexing.mdx index 0326c6db324..a5784102031 100644 --- a/docs/howtos/quick-start/cli/_cli-secondary-indexing.mdx +++ b/docs/howtos/quick-start/cli/_cli-secondary-indexing.mdx @@ -1,73 +1,73 @@ -**RedisJSON** adds JSON data type for Redis. +Redis Stack enables the JSON data type in Redis. -```sh +```shell # syntax : set an object value to a key -JSON.SET objKey $ value +> JSON.SET objKey $ value # example -JSON.SET person $ '{"name":"Leonard Cohen","dob":1478476800,"isActive": true, "hobbies":["music", "cricket"]}' +> JSON.SET person $ '{"name":"Leonard Cohen","dob":1478476800,"isActive": true, "hobbies":["music", "cricket"]}' #------------ # syntax : get object value of a key -JSON.GET objKey $ +> JSON.GET objKey $ # example -JSON.GET person $ +> JSON.GET person $ #------------ # syntax : find object key length -JSON.OBJLEN objKey $ +> JSON.OBJLEN objKey $ # example -JSON.OBJLEN person $ +> JSON.OBJLEN person $ #------------ # syntax : find object keys -JSON.OBJKEYS objKey $ +> JSON.OBJKEYS objKey $ # example -JSON.OBJKEYS person $ +> JSON.OBJKEYS person $ #------------ # syntax : update nested property -JSON.SET objKey $.prop value +> JSON.SET objKey $.prop value # example -JSON.SET person $.name '"Alex"' +> JSON.SET person $.name '"Alex"' #------------ # syntax : update nested array -JSON.SET objKey $.arrayProp fullValue -JSON.SET objKey $.arrayProp[index] value +> JSON.SET objKey $.arrayProp fullValue +> JSON.SET objKey $.arrayProp[index] value # example -JSON.SET person $.hobbies '["music", "cricket"]' -JSON.SET person $.hobbies[1] '"dance"' +> JSON.SET person $.hobbies '["music", "cricket"]' +> JSON.SET person $.hobbies[1] '"dance"' #------------ # syntax : remove nested array item by index -JSON.ARRPOP objKey $.arrayProp index +> JSON.ARRPOP objKey $.arrayProp index # example -JSON.ARRPOP person $.hobbies 1 +> JSON.ARRPOP person $.hobbies 1 ``` -More RedisJSON details can be found in [docs](https://redis.io/docs/stack/json/) +More details can be found in the [Redis Stack docs](https://redis.io/docs/stack/json/) --- -**Redis Search** is a query and indexing engine for Redis, providing secondary indexing, full-text search and aggregations capabilities. +Redis Stack enables a query and indexing engine for Redis, providing secondary indexing, full-text search and aggregations capabilities. - We have to create index on schema to be able to search on its data -```sh +```shell # syntax -FT.CREATE {index_name} ON JSON SCHEMA {json_path} AS {attribute} {type} +> FT.CREATE {index_name} ON JSON SCHEMA {json_path} AS {attribute} {type} # note : attribute = logical name, json_path = JSONPath expressions # example -FT.CREATE userIdx ON JSON SCHEMA $.user.name AS name TEXT $.user.hobbies AS hobbies TAG $.user.age as age NUMERIC +> FT.CREATE userIdx ON JSON SCHEMA $.user.name AS name TEXT $.user.hobbies AS hobbies TAG $.user.age as age NUMERIC # note : Can search by any attribute mentioned in the above index. ``` @@ -86,18 +86,16 @@ Once index is created, any pre-existing/ new/ modified JSON document is automati } ``` -```sh +```shell # adding JSON document -JSON.SET myDoc $ '{"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}' +> JSON.SET myDoc $ '{"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}' ``` - Search -```sh +```shell # search all user documents with name 'John' -FT.SEARCH userIdx '@name:(John)' - -# output +> FT.SEARCH userIdx '@name:(John)' 1) (integer) 1 2) "myDoc" 3) 1) "$" @@ -106,22 +104,18 @@ FT.SEARCH userIdx '@name:(John)' - Search & project required fields -```sh +```shell # search documents with name 'John' & project only age field -FT.SEARCH userIdx '@name:(John)' RETURN 1 $.user.age - -# output +> FT.SEARCH userIdx '@name:(John)' RETURN 1 $.user.age 1) (integer) 1 2) "myDoc" 3) 1) "$.user.age" 2) "23" ``` -```sh +```shell # project multiple fields -FT.SEARCH userIdx '@name:(John)' RETURN 2 $.user.age $.user.name - -# output +> FT.SEARCH userIdx '@name:(John)' RETURN 2 $.user.age $.user.name 1) (integer) 1 2) "myDoc" 3) 1) "$.user.age" @@ -131,7 +125,7 @@ FT.SEARCH userIdx '@name:(John)' RETURN 2 $.user.age $.user.name #------------ # project with alias name -FT.SEARCH userIdx '@name:(John)' RETURN 3 $.user.age AS userAge +> FT.SEARCH userIdx '@name:(John)' RETURN 3 $.user.age AS userAge 1) (integer) 1 2) "myDoc" @@ -140,9 +134,7 @@ FT.SEARCH userIdx '@name:(John)' RETURN 3 $.user.age AS userAge #------------ # multi field query -FT.SEARCH userIdx '@name:(John) @hobbies:{foo | me} @age:[20 30]' - -# output +> FT.SEARCH userIdx '@name:(John) @hobbies:{foo | me} @age:[20 30]' 1) (integer) 1 2) "myDoc" 3) 1) "$" @@ -153,8 +145,8 @@ More details on [query syntax](https://redis.io/docs/stack/search/reference/quer - Drop index -```sh -FT.DROPINDEX userIdx +```shell +> FT.DROPINDEX userIdx ``` Watch video [RediSearch (RedisConf 2020)](https://www.youtube.com/watch?v=9R29LLWquME), also more details can be found in [docs](https://redis.io/docs/stack/search/) diff --git a/docs/howtos/quick-start/index-quick-start.mdx b/docs/howtos/quick-start/index-quick-start.mdx index 9de015c3673..2f72a46cd6d 100644 --- a/docs/howtos/quick-start/index-quick-start.mdx +++ b/docs/howtos/quick-start/index-quick-start.mdx @@ -219,13 +219,13 @@ The code above demonstrates how you would sync a "movies" collection in MongoDB To get this working you first need to load the python file into redis-server: -```sh -redis-cli rg.pyexecute "`cat write-behind.py`" REQUIREMENTS rgsync pymongo==3.12.0 +```shell +$ redis-cli rg.pyexecute "`cat write-behind.py`" REQUIREMENTS rgsync pymongo==3.12.0 ``` Now, insert a JSON item in to Redis starting with the prefix specified in the python file (i.e. "movie"): -```sh +```shell # redis-cli command > JSON.SET movie:123 $ '{"movieId":123,"name":"RRR","isActive": true}' ``` @@ -244,7 +244,7 @@ Now, verify whether the JSON is inserted into MongoDB. Redis Stack supports probabilistic datatypes and queries. Below you will find a stock leaderboard example: -```sh +```shell # Reserve a new leaderboard filter > TOPK.RESERVE trending-stocks 12 50 4 0.9 "OK" diff --git a/docs/howtos/quick-start/node/_node-basic-querying.mdx b/docs/howtos/quick-start/node/_node-basic-querying.mdx index c0c7b9fe75c..1625dcc994d 100644 --- a/docs/howtos/quick-start/node/_node-basic-querying.mdx +++ b/docs/howtos/quick-start/node/_node-basic-querying.mdx @@ -1,5 +1,5 @@ -```sh +```shell # install redis in the project npm install redis --save ``` diff --git a/docs/howtos/quick-start/node/_node-secondary-indexing.mdx b/docs/howtos/quick-start/node/_node-secondary-indexing.mdx index dc51be7cf8a..5732dc9cfbb 100644 --- a/docs/howtos/quick-start/node/_node-secondary-indexing.mdx +++ b/docs/howtos/quick-start/node/_node-secondary-indexing.mdx @@ -1,7 +1,7 @@ The following example uses [Redis OM Node](https://github.com/redis/redis-om-node), but you can also use [Node Redis](https://github.com/redis/node-redis), [IO Redis](https://github.com/luin/ioredis), or any other supported [client](https://redis.io/resources/clients/) -```sh +```shell # install RedisOM in the project npm install redis-om --save ``` diff --git a/docs/howtos/quick-start/python/_python-basic-querying.mdx b/docs/howtos/quick-start/python/_python-basic-querying.mdx index 682f186cb35..f50c68558d7 100644 --- a/docs/howtos/quick-start/python/_python-basic-querying.mdx +++ b/docs/howtos/quick-start/python/_python-basic-querying.mdx @@ -1,5 +1,5 @@ -```sh +```shell # install redis in the project pip install redis ``` diff --git a/docs/howtos/quick-start/python/_python-secondary-indexing.mdx b/docs/howtos/quick-start/python/_python-secondary-indexing.mdx index fcf5c21befa..3a863d81d84 100644 --- a/docs/howtos/quick-start/python/_python-secondary-indexing.mdx +++ b/docs/howtos/quick-start/python/_python-secondary-indexing.mdx @@ -1,6 +1,6 @@ The following example uses [Redis OM Python](https://github.com/redis/redis-om-python), but you can also use [redis-py](https://github.com/redis/redis-py) or any other supported [client](https://redis.io/resources/clients/) -```sh +```shell # install Redis OM in the project pip install redis-om ``` diff --git a/docs/howtos/quick-start/setup/_docker-setup.mdx b/docs/howtos/quick-start/setup/_docker-setup.mdx index 93fb23f755a..82b531b793f 100644 --- a/docs/howtos/quick-start/setup/_docker-setup.mdx +++ b/docs/howtos/quick-start/setup/_docker-setup.mdx @@ -1,16 +1,16 @@ The `docker run` command below exposes redis-server on port 6379 and RedisInsight on port 8001. You can use RedisInsight by pointing your browser to http://localhost:8001. -```sh +```shell # install -docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest +$ docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest ``` You can use `redis-cli` to connect to the server at localhost:6379. If you don’t have `redis-cli` installed locally, you can run it from the Docker container like below: -```sh +```shell # connect -docker exec -it redis-stack redis-cli +$ docker exec -it redis-stack redis-cli ``` Detailed Docker instructions can be viewed [here](/create/docker/redis-on-docker) diff --git a/docs/howtos/quick-start/setup/_linux-setup.mdx b/docs/howtos/quick-start/setup/_linux-setup.mdx index 1220fd95e75..19a8f4874e8 100644 --- a/docs/howtos/quick-start/setup/_linux-setup.mdx +++ b/docs/howtos/quick-start/setup/_linux-setup.mdx @@ -4,7 +4,7 @@ Works with Ubuntu 16.04, 18.04, or 20.04 and Debian 11 -```sh +```shell curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list sudo apt-get update @@ -25,7 +25,7 @@ enabled=1 gpgcheck=1 ``` -```sh +```shell curl -fsSL https://packages.redis.io/gpg > /tmp/redis.key sudo rpm --import /tmp/redis.key sudo yum install epel-release @@ -38,8 +38,8 @@ Download the [latest Redis Stack snap package](https://redis.io/download/#redis- To install, run: -```sh -sudo snap install --dangerous --classic +```shell +$ sudo snap install --dangerous --classic ``` ### With AppImage @@ -48,14 +48,14 @@ Download the [latest Redis Stack AppImage package](https://redis.io/download/#re To enable the install, run: -```sh -chmod a+x +```shell +$ chmod a+x ``` To install run: -```sh -./ +```shell +$ ./ ``` Detailed Linux instructions can be viewed [here](/create/linux/) diff --git a/docs/howtos/quick-start/setup/_macos-setup.mdx b/docs/howtos/quick-start/setup/_macos-setup.mdx index 58882d589ec..38c0f405bce 100644 --- a/docs/howtos/quick-start/setup/_macos-setup.mdx +++ b/docs/howtos/quick-start/setup/_macos-setup.mdx @@ -1,10 +1,10 @@ -```sh +```shell # install redis-stack -brew tap redis-stack/redis-stack -brew install --cask redis-stack +$ brew tap redis-stack/redis-stack +$ brew install --cask redis-stack # start redis-stack -redis-stack-server +$ redis-stack-server ``` Detailed MacOS instructions can be viewed [here](/create/homebrew/) From 0c969a284d27b55516bce8eefc25bf214f0c1f23 Mon Sep 17 00:00:00 2001 From: William Johnston Date: Fri, 30 Dec 2022 12:01:33 -0800 Subject: [PATCH 11/16] adding c# basic commands --- .../csharp/_csharp-basic-querying.mdx | 79 ++++++++++++++++++- docs/howtos/quick-start/index-quick-start.mdx | 4 +- .../quick-start/node/_node-basic-querying.mdx | 31 ++++---- .../python/_python-basic-querying.mdx | 29 ++++--- 4 files changed, 114 insertions(+), 29 deletions(-) diff --git a/docs/howtos/quick-start/csharp/_csharp-basic-querying.mdx b/docs/howtos/quick-start/csharp/_csharp-basic-querying.mdx index 0ec8b083d10..59d6d57644e 100644 --- a/docs/howtos/quick-start/csharp/_csharp-basic-querying.mdx +++ b/docs/howtos/quick-start/csharp/_csharp-basic-querying.mdx @@ -1 +1,78 @@ -TODO: Examples coming soon +The .NET Community has built many [client libraries](https://redis.io/clients#c-sharp) to help handle requests to Redis Server. In this guide, we'll mostly be concerned with using the [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis) client library. As the name implies the StackExchange client is developed by StackExchange for use on popular websites like [StackOverflow](https://stackoverflow.com/). + +```shell +# install redis in the project +dotnet add package StackExchange.Redis +``` + +```csharp +// Impport the required namespace +using StackExchange.Redis; + +// Initialize the connection +static readonly ConnectionMultiplexer _redis = ConnectionMultiplexer.Connect("localhost:6379"); +``` + +```csharp +var redis = _redis.GetDatabase(); + +// Check specific keys +var server = _redis.GetServer(_redis.GetEndPoints()[0]); +server.Keys(pattern: "*"); + +//------------ +// Check number of keys in database +server.DatabaseSize(); + +//------------ +// set key value +redis.StringSet("key", "value"); +redis.StringSet("key", "value", expiry: TimeSpan.FromSeconds(10), when: When.NotExists); + +//------------ +// get value by key +var value = redis.StringGet("key"); + +//------------ +// syntax : delete keys +redis.KeyDelete("key"); +redis.KeyDelete(new RedisKey[] { "key1", "key2", "key3"}); + +//------------ +// Check if key exists +redis.KeyExists("key"); + +//------------ +// set expiry to key +redis.KeyExpire("key", DateTime.Now.AddSeconds(30)); + +//------------ +// remove expiry from key +redis.KeyPersist("key"); + + +//------------ +// find (remaining) time to live of a key +redis.KeyTimeToLive("key"); + + +//------------ +// increment a number +redis.StringIncrement("key"); + + +//------------ +// decrement a number +redis.StringDecrement("key"); + + +//------------ +// use the method below to execute commands directly +redis.Execute("SET", "key", "value"); +``` + +### Additional Resources + +1. [StackExchange.Redis Github repo](https://github.com/StackExchange/StackExchange.Redis) +1. [Detailed .NET Guide](/develop/dotnet) +1. C# apps on the [Redis Launchpad](https://launchpad.redis.com/) diff --git a/docs/howtos/quick-start/index-quick-start.mdx b/docs/howtos/quick-start/index-quick-start.mdx index 2f72a46cd6d..a044f80e7de 100644 --- a/docs/howtos/quick-start/index-quick-start.mdx +++ b/docs/howtos/quick-start/index-quick-start.mdx @@ -96,7 +96,7 @@ If you choose to use local Redis we strongly recommend using Docker. If you choo groupId="language" values={[ {label: 'CLI', value: 'CLI'}, - {label: 'JavaScript/Node.js', value: 'JS'}, + {label: 'JavaScript', value: 'JS'}, {label: 'Python', value: 'PYTHON'}, //{label: 'C#', value: 'C#'}, //{label: 'Java', value: 'JAVA'}, @@ -140,7 +140,7 @@ If you choose to use local Redis we strongly recommend using Docker. If you choo groupId="language" values={[ {label: 'CLI', value: 'CLI'}, - {label: 'JavaScript/Node.js', value: 'JS'}, + {label: 'JavaScript', value: 'JS'}, {label: 'Python', value: 'PYTHON'}, //{label: 'C#', value: 'C#'}, //{label: 'Java', value: 'JAVA'}, diff --git a/docs/howtos/quick-start/node/_node-basic-querying.mdx b/docs/howtos/quick-start/node/_node-basic-querying.mdx index 1625dcc994d..e1c2b783e94 100644 --- a/docs/howtos/quick-start/node/_node-basic-querying.mdx +++ b/docs/howtos/quick-start/node/_node-basic-querying.mdx @@ -1,4 +1,3 @@ - ```shell # install redis in the project npm install redis --save @@ -24,11 +23,11 @@ await client.connect(); const pattern = '*'; await client.keys(pattern); -#------------ +//------------ // Check number of keys in database await client.dbsize(); -#------------ +//------------ // set key value await client.set('key', 'value'); await client.set('key', 'value', { @@ -36,43 +35,43 @@ await client.set('key', 'value', { NX: true, }); -#------------ +//------------ // get value by key const value = await client.get('key'); -#------------ +//------------ //syntax : delete keys await client.del('key'); const keyArr = ['key1', 'key2', 'key3']; await client.del(...keyArr); -#------------ +//------------ // Check if key exists await client.exists('key'); -#------------ +//------------ // set expiry to key const expireInSeconds = 30; await client.expire('key', expireInSeconds); -#------------ +//------------ // remove expiry from key await client.persist('key'); -#------------ +//------------ // find (remaining) time to live of a key await client.ttl('key'); -#------------ +//------------ // increment a number await client.incr('key'); -#------------ +//------------ // decrement a number await client.decr('key'); -#------------ -//use below style for unsupported commands by client library +//------------ +// use the method below to execute commands directly await client.sendCommand(['SET', 'key', 'value']); ``` @@ -84,4 +83,8 @@ await client.quit(); await client.disconnect(); ``` -- For more information visit the [node-redis Github repo](https://github.com/redis/node-redis), and also check JavaScript/NodeJS apps at [Redis Launchpad](https://launchpad.redis.com/) +### Additional Resources + +1. [node-redis Github repo](https://github.com/redis/node-redis) +1. [Node.js Redis Crash Course](/develop/node/node-crash-course) +1. JavaScript/NodeJS apps on the [Redis Launchpad](https://launchpad.redis.com/) diff --git a/docs/howtos/quick-start/python/_python-basic-querying.mdx b/docs/howtos/quick-start/python/_python-basic-querying.mdx index f50c68558d7..c3fae8b6d11 100644 --- a/docs/howtos/quick-start/python/_python-basic-querying.mdx +++ b/docs/howtos/quick-start/python/_python-basic-querying.mdx @@ -1,4 +1,3 @@ - ```shell # install redis in the project pip install redis @@ -14,16 +13,16 @@ r = redis.Redis(connection_pool=pool) r.keys('*') #------------ -# Check number of keys in database +# Check number of keys in database r.dbsize() #------------ -# set key value +# set key value r.set('key', 'value') r.set('key', 'value', ex=10, nx=True) #------------ -# get value by key +# get value by key value = r.get('key') #------------ @@ -32,33 +31,39 @@ r.delete('key') r.delete('key1', 'key2', 'key3') #------------ -# Check if key exists +# Check if key exists r.exists('key') #------------ -# set expiry to key +# set expiry to key expireInSeconds = 30 r.expire('key', expireInSeconds) #------------ -# remove expiry from key +# remove expiry from key r.persist('key') #------------ -# find (remaining) time to live of a key +# find (remaining) time to live of a key r.ttl('key') #------------ -# increment a number +# increment a number r.incr('key') #------------ -# decrement a number +# decrement a number r.decr('key') #------------ -# use below style for unsupported commands by client library +# use the method below to execute commands directly r.execute_command('SET', 'key', 'value') ``` -- For more information, checkout the [redis-py Github repo](https://github.com/redis/redis-py) +- For more information, checkout the + +### Additional Resources + +1. [redis-py Github repo](https://github.com/redis/redis-py) +1. [Using Redis with Python and FastAPI](/develop/python/fastapi) +1. Python apps on the [Redis Launchpad](https://launchpad.redis.com/) From 4c13bacaf762ad24f04c15659b944d4d506cc7b1 Mon Sep 17 00:00:00 2001 From: William Johnston Date: Fri, 30 Dec 2022 17:06:40 -0800 Subject: [PATCH 12/16] finishing the Redis OM .NET getting started doc and enabling it in the menu --- .../csharp/_csharp-secondary-indexing.mdx | 160 +++++++++++++++++- docs/howtos/quick-start/index-quick-start.mdx | 12 +- .../python/_python-secondary-indexing.mdx | 6 +- 3 files changed, 168 insertions(+), 10 deletions(-) diff --git a/docs/howtos/quick-start/csharp/_csharp-secondary-indexing.mdx b/docs/howtos/quick-start/csharp/_csharp-secondary-indexing.mdx index 0ec8b083d10..2edd1b7faf3 100644 --- a/docs/howtos/quick-start/csharp/_csharp-secondary-indexing.mdx +++ b/docs/howtos/quick-start/csharp/_csharp-secondary-indexing.mdx @@ -1 +1,159 @@ -TODO: Examples coming soon +The following example uses [Redis OM .NET](https://github.com/redis/redis-om-dotnet), but you can also use any other supported [client](https://redis.io/resources/clients/). The examples also use the synchronous methods of Redis OM .NET, but it is recommended that you use the asynchronous methods in a production application. + +```shell +# install Redis OM in the project +dotnet add package Redis.OM +``` + +- Create a JSON model + +```csharp title="Model.cs" +using Redis.OM.Modeling; + +namespace RedisApp.Model +{ + [Document(StorageType = StorageType.Json, Prefixes = new[] { "Person" })] + public class Person + { + [RedisIdField] + public string Id { get; set; } + + [Indexed] + public string FirstName { get; set; } + + [Indexed] + public string? LastName { get; set; } + + [Indexed(Sortable = true)] + public int Age { get; set; } + + [Indexed] + public bool Verified { get; set; } + + [Indexed] + public GeoLoc Location { get; set; } + + [Indexed] + public string[] Skills { get; set; } = Array.Empty(); + + [Searchable] + public string PersonalStatement { get; set; } + } +} +``` + +- Setup your main program + +```csharp title="Program.cs" +using System; +using System.Linq; +using Redis.OM; +using Redis.OM.Modeling; +using RedisApp.Model; + +namespace RedisApp +{ + class Program + { + static void Main(string[] args) + { + + } + } +} +``` + +The rest of the code will be inside of `Main`. + +- Create your provider used to call into Redis + +```csharp +var provider = new RedisConnectionProvider("redis://localhost:6379"); +``` + +- Conditionally create index necessary for searching + +```csharp +var info = provider.Connection.Execute("FT._LIST").ToArray().Select(x => x.ToString()); + +if (info.All(x => x != "person-idx")) +{ + provider.Connection.CreateIndex(typeof(Person)); +} +``` + +- Initialize your collection + +```csharp +var people = provider.RedisCollection(); +``` + +- Insert example + +```csharp +var person = new Person +{ + FirstName = "Rupert", + LastName = "Holmes", + Age = 75, + Verified = false, + Location = new GeoLoc { Longitude = 45.678, Latitude = 45.678 }, + Skills = new string[] { "singing", "songwriting", "playwriting" }, + PersonalStatement = "I like piña coladas and walks in the rain" +}; + +var id = people.Insert(person); +``` + +- Read example + +```csharp +person = people.FindById(id); +``` + +- Update example + +```csharp +person = people.FindById(id); +person.FirstName = "Alex"; +person.LastName = null; +people.Update(person); +``` + +- Update location example + +```csharp +person = people.FindById(id); +person.Location = new GeoLoc { Longitude = 44.678, Latitude = 44.678 }; +people.Update(person); +``` + +- Search examples + +```csharp +// Multiple AND conditions example +people.Where(p => p.Age > 21 && p.FirstName == "Alex").ToList(); + +// Multiple OR conditions example +people.Where(p => p.Age > 75 || p.FirstName == "Alex").ToList(); + +// Multiple AND + OR conditions example +people.Where(p => + (p.Age > 21 && p.FirstName == "Alex") && + (p.Age > 75 || p.FirstName == "Alex") +).ToList(); +``` + +- Delete example + +```csharp +person = people.FindById(id); +people.Delete(person); +``` + +### Useful Resources + +1. [Github repo](https://github.com/redis/redis-om-dotnet) +1. [Getting started docs](https://redis.io/docs/stack/get-started/tutorials/stack-dotnet/) +1. [Getting started video](https://www.youtube.com/watch?v=ZHPXKrJCYNA) + - [Source code](https://github.com/redis-developer/redis-om-dotnet-skeleton-app) diff --git a/docs/howtos/quick-start/index-quick-start.mdx b/docs/howtos/quick-start/index-quick-start.mdx index a044f80e7de..a6f4e1732b0 100644 --- a/docs/howtos/quick-start/index-quick-start.mdx +++ b/docs/howtos/quick-start/index-quick-start.mdx @@ -98,7 +98,7 @@ If you choose to use local Redis we strongly recommend using Docker. If you choo {label: 'CLI', value: 'CLI'}, {label: 'JavaScript', value: 'JS'}, {label: 'Python', value: 'PYTHON'}, - //{label: 'C#', value: 'C#'}, + {label: 'C#', value: 'C#'}, //{label: 'Java', value: 'JAVA'}, ]}> @@ -120,13 +120,13 @@ If you choose to use local Redis we strongly recommend using Docker. If you choo -