How to create and remove a key in Redis database

How to create a Redis key

set user:1 '{nome: "Victor", sobrenome: "Hugo"}'
set user:2 '{nome: "Vinicius", sobrenome: "Albuquerque"}'
set user:3 '{nome: "Thiago", sobrenome: "Santos"}'

How to delete all keys that start with the text “user”

redis-cli KEYS "user*" | xargs redis-cli DEL

How to delete a unique key in Redis

redis-cli DEL user:3

Spring Data + Pagination

How to do pagination using Spring Data

PessoaRepository.java

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface PessoaRepository extends JpaRepository<Pessoa, Long> {

@Query("FROM Pessoa pessoa where pessoa.nome = 'Victor')
List getAllPessoas(Pageable paginacao);
}

PessoaService.java

import java.util.List;
import org.springframework.data.domain.Pageable;

@Service
@Transactional(rollbackFor=Exception.class)
public class PessoaService {
public List getAllPessoas() {
//pagination here
//passing the pagination like parameter
Pageable pageable = new PageRequest(0, 15);

return pessoaRepository.getAllPessoas(pageable);
}
}