Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
59da384
new getting started page
PrasanKumar93 Nov 8, 2022
54151ff
quickstart - redis modules
PrasanKumar93 Nov 8, 2022
fcd0a5d
commenting quick start navigation
PrasanKumar93 Nov 14, 2022
3bfad18
Merge branch 'master' into quick-start-new
PrasanKumar93 Nov 14, 2022
c9e14a3
Adding partials to break out quick-start
wjohnsto Nov 14, 2022
9535954
Merge pull request #1 from wjohnsto/PrasanKumar93-master
PrasanKumar93 Nov 14, 2022
e918c4f
finishing python doc, adjusting node doc to match message, setting up…
wjohnsto Dec 29, 2022
05aec27
nodejs quick start code is now a continuous example
wjohnsto Dec 29, 2022
aea0bf1
hiding java and c# until they are complete
wjohnsto Dec 29, 2022
3d19fe2
adjusting headers and language
wjohnsto Dec 29, 2022
a4624e8
longer, non-image module examples
wjohnsto Dec 29, 2022
873ed3d
more language cleanup, sh -> shell
wjohnsto Dec 29, 2022
0c969a2
adding c# basic commands
wjohnsto Dec 30, 2022
4c13bac
finishing the Redis OM .NET getting started doc and enabling it in th…
wjohnsto Dec 31, 2022
e1f937d
switching Get Started to go to proper URL
wjohnsto Jan 4, 2023
805a7cf
Merge branch 'redis-developer:master' into master
PrasanKumar93 Jan 5, 2023
52395c6
Merge pull request #2 from wjohnsto/PrasanKumar93-master
PrasanKumar93 Jan 5, 2023
c22ac65
Merge remote-tracking branch 'prasan/master'
wjohnsto Jan 17, 2023
72ddcb4
Adding Windows usage video to getting started
wjohnsto Jan 17, 2023
4dfd229
encapsulating URL, using AUTH not -a, adding PREFIX
wjohnsto Jan 17, 2023
acf0ddb
adding up-to-date useful resources for secondary indexing
wjohnsto Jan 17, 2023
e79d7e6
Merge pull request #3 from wjohnsto/master
PrasanKumar93 Jan 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions docs/create/linux/index-linux.mdx
Original file line number Diff line number Diff line change
@@ -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';

<Authors frontMatter={frontMatter} />

### 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
```
104 changes: 104 additions & 0 deletions docs/howtos/quick-start/cli/_cli-basic-querying.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@

- 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)

```shell
# syntax 1 : connect using host & port, followed by password
$ redis-cli -h host -p port
> AUTH password
OK

# example 1
$ redis-cli -h redis15.localnet.org -p 6390
> AUTH myUnguessablePassword
OK

# 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

```shell
# 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/)
156 changes: 156 additions & 0 deletions docs/howtos/quick-start/cli/_cli-secondary-indexing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@

Redis Stack enables the JSON data type in Redis.

```shell
# 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 details can be found in the [Redis Stack docs](https://redis.io/docs/stack/json/)

---

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

```shell
# syntax
> FT.CREATE {index_name} ON JSON PREFIX {count} {prefix} SCHEMA {json_path} AS {attribute} {type}
# NOTE: attribute = logical name, json_path = JSONPath expressions

# example
> FT.CREATE userIdx ON JSON PREFIX 1 users: SCHEMA $.user.name AS name TEXT $.user.hobbies AS hobbies TAG $.user.age as age NUMERIC
# NOTE: You can search by any attribute mentioned in the above index for keys that start with users: (e.g. users:1).
```

- 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
}
}
```

```shell
# adding JSON document
> JSON.SET myDoc $ '{"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}'
```

- Search

```shell
# search all user documents with name 'John'
> FT.SEARCH userIdx '@name:(John)'
1) (integer) 1
2) "myDoc"
3) 1) "$"
2) {"user":{"name":"John Smith","hobbies":"foo,bar","age":23}}"
```

- Search & project required fields

```shell
# search documents with name 'John' & project only age field
> FT.SEARCH userIdx '@name:(John)' RETURN 1 $.user.age
1) (integer) 1
2) "myDoc"
3) 1) "$.user.age"
2) "23"
```

```shell
# project multiple fields
> FT.SEARCH userIdx '@name:(John)' RETURN 2 $.user.age $.user.name
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]'
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

```shell
> FT.DROPINDEX userIdx
```

### Useful Resources

1. [Redis and JSON explained (Revisited in 2022)](https://www.youtube.com/watch?v=I-ohlZXXaxs) video
1. [Searching with Redis Stack](https://redis.io/docs/stack/search/)
1. [Redis University 204, Storing, Querying, and Indexing JSON at Speed](https://university.redis.com/courses/ru204/)
78 changes: 78 additions & 0 deletions docs/howtos/quick-start/csharp/_csharp-basic-querying.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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/)
Loading