专栏首页readmeredis helloworld
原创

redis helloworld

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams. 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.

REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统。Redis是一个开源的使用ANSI C语言编写、遵守BSD协议、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。它通常被称为数据结构服务器,因为值(value)可以是 字符串(String), 哈希(Hash), 列表(list), 集合(sets) 和 有序集合(sorted sets)等类型。

server - python - django:

# setting.py
# pip3 install django-redis
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "PICKLE_VERSION": -1,
            # "PASSWORD": "SECRET",
        }
    }
}
# redis-server
# view.py
# pip install django==2.2.7
from django.core.cache import cache
from parking.models import *
def redis_pool(key_id, val_dt=None):
    try:
        if val_dt is None: return cache.get(key_id)
        cache.set(key_id, val_dt); return True
    except: return False
try:
    redis_pool('hello', 'world')
    print(redis_pool('hello'))
except Exception as e:
    print(e)

server Installation - linux:

# linux (centos7)
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
tar -zvxf redis-5.0.7.tar.gz
make && make install
mkdir /etc/local/redis
mkdir /etc/local/redis/bin/
mkdir /etc/local/redis/etc/
mv redis.conf /usr/local/redis/etc/
cd src
mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-server /usr/local/redis/bin/
./redis-serve
# more config
bind 127.0.0.1
vi /usr/local/redis/etc/redis.conf
daemonize -> yes
redis-server /usr/local/redis/etc/redis.conf
ln -s /usr/local/redis/bin/redis-server /usr/bin/redis-server
# yum
yum install redis / yum install epel-release
yum install redis 
# apt
sudo apt-get install redis-server
sudo apt-get purge --auto-remove redis-server
# Runtime (centOS7 / unbuntu)
service redis start / sudo service redis-server start
service redis stop / sudo service redis-server stop 
service redis status / ps aux|grep redis
ps -ef | grep redis
# auto start
chkconfig redis on
# windows https://github.com/microsoftarchive/redis/releases
# macos
# brew update
# brew install redis
# brew services start redis
# redis-server /usr/local/etc/redis.conf # background service
# redis-cli ping # runtime check
# /usr/local/etc/redis.conf
# brew uninstall redis # uninstall
# rm ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

client test - python

import redis # pip install redis
r = redis.Redis(host="10.170.15.54", port='6379')
r.set('hello','there')
print((r.get('hello')))

https://django-redis-chs.readthedocs.io/zh_CN/latest/

原创声明,本文系作者授权云+社区发表,未经许可,不得转载。

如有侵权,请联系 yunjia_community@tencent.com 删除。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • mongodb helloworld

    readme
  • point inside 点在框内

    如果是矩形比较简单,直接判断四个点的范围,不能推广到多边,考虑到图形的凹凸就更复杂,考虑到程序需要直接拿来用罢了,

    readme
  • sublime homebrew configuration

    readme
  • Ubuntu 安装 Redis

    Redis,is an open source, BSD licensed, advanced key-value store. It is often ref...

    阳光岛主
  • Docker -v 对挂载的目录没有权限 Permission denied

    可以通过docker inspect命令,查看容器“Mounts”那一部分,我们可以得到这个问题的答案。

    hbbliyong
  • 使用redis为Typecho博客加速

    REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统。 Redis是...

    小柒吃地瓜
  • redis-基本介绍与linux安装

    HyperLogLog:超小内存唯一值计数,12kb HyperLogLog,本质是字符串

    suwanbin
  • 05. SpringCloud实战项目-Docker安装mysql

    Jackson0714
  • docker安装redis

    Jackson0714
  • redis单机版,集群版,jedis

    redis是一个开源的key-value数据库。主要用来做数据缓存,本篇文章介绍redis的单机搭建,进而到redis的集群搭建,刚接触的可以先搭建单机版的,再...

    聚沙成塔

扫码关注云+社区

领取腾讯云代金券