Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to operate redis

Shulou Source: shulou.com Published: 2022-06-01 04:59:29 09月24日 Update

This article will explain in detail how to operate redis for everyone, Xiaobian thinks it is quite practical, so share it with everyone for a reference, I hope you can gain something after reading this article.

Redis is a high-performance key-value database. The emergence of redis largely compensates for the lack of keyvalue storage such as memcached, which can complement relational databases in some cases. It provides Python, Ruby, Erlang, PHP client, easy to use.

Redis is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

Redis is an open source software that can be used as a database, cache and message broker, supports complex data structures, redis natively supports replicas, least-recently used retirement policies and transaction options, provides different levels of consistency, and provides high availability through sentinel mode and cluster automatic allocation.

Let me start with the simplest example of stand-alone redis.

Redis official is no win version, but Microsoft Open Tech group on GitHub developed a win version of redis, project address: https://github.com/MSOpenTech/redis, software release address: https://github.com/MSOpenTech/redis/releases. Download it, cd it to redis directory and execute redis-server.exe redis.windows.conf to start redis, redis default port is 6379

Search the maven repository for jedis jar packages to add to the project, and then you can operate redis.

package redisOne;import redis.clients.jedis.Jedis;public class RedisUtil{ private static Jedis jedis=new Jedis("127.0.0.1", 6379); public static String getOneKey(String key){ String value=jedis.get(key); jedis.close(); return value; } public static void setOneKey(String key,String value){ jedis.set(key,value); jedis.close(); } public static void main(String[] args) { RedisUtil.setOneKey("liuc","liuc"); System.out.println(RedisUtil.getOneKey("liuc")); }} About "how to operate redis" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Tags: Data database article address more version software support different good complex practical large consistent consistent transaction warehouse role field copy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Tech Info OPPO Reno vpn NVidia