Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Another redis python client :) redis-cli-py provides friendly access to redis (on both normal python apps and kubernetes apps), separating initialization and keys operation with borg pattern.
You will have full features of official redis-py, for the principle of this client is focusing on init, the interface you actually work with IS class Redis itself from redis-py, without wrapping, which will compatible with multiple versions of redis-py, including these in the future.
$ pip install redis-cli
# this is requirements.txt
# git+https://gitee.com/will4j/redis-cli-py.git@main#egg=redis-cli
git+https://github.com/will4j/redis-cli-py.git@main#egg=redis-cli
$ pip install -r requirements.txt
>>> import redis_cli
>>> redis_cli.init_from_url("redis://localhost:6379")
>>>
>>> from redis_cli import get_redis
>>> get_redis().set('foo', 'bar')
True
>>> get_redis().get('foo')
b'bar'
TIPS: Both Redis and Sentinel actually use connectionpool internel, so do not bother with connectionpool.
NOTICE: You can init redis_cli multiple times, but only one shared Redis instance will exists.
import redis_cli
import redis
# from Redis instance
r = redis.Redis(host='localhost', port=6379, db=0)
redis_cli.init_from_redis(r)
# from Sentinel instance
s = redis.Sentinel([('localhost', 26379)], socket_timeout=0.1)
redis_cli.init_from_sentinel(s, 'mymaster')
Scheme redis/rediss/unix will delegate to redis.from_url.
Scheme redis+sentinel will be parsed, return master Redis (which can both read & write) or slave Redis (which is readonly),according to url param readonly
(default false).
import redis_cli
# from redis/rediss/unix url
redis_cli.init_from_url('redis://:password@localhost:6379/0')
redis_cli.init_from_url('rediss://localhost:6379/0')
redis_cli.init_from_url('unix://path/to/socket.sock?db=0')
# from sentinel url
redis_cli.init_from_url('redis-sentinel://username:password@host1:1,host2,host3:3/mymaster/0?readonly=true')
This could be useful when deploy apps in kubernetes environment.
NOTICE: password
from url has the highest priority, then from env REDISCLI_AUTH
.
export REDISCLI_URL='redis-sentinel://host:26379/mymaster/0'
export REDISCLI_AUTH='complicated#pass'
import redis_cli
# above env REDISCLI_URL and REDISCLI_AUTH will take over
redis_cli.init_from_url('redis://:password@localhost:6379/0')
Create a redis auth config secret:
apiVersion: v1
kind: Secret
metadata:
name: redis-auth-conf-secret
type: Opaque
data:
REDISCLI_URL: "redis-sentinel://host:26379/mymaster/0" # base64
REDISCLI_AUTH: "complicated#pass" # base64
Mount environment variable in deployment config:
# ...
containers:
- name: your container
# ...
envFrom:
- secretRef:
name: redis-auth-conf-secret
# ...
Then init redis at app startup:
import redis_cli
redis_cli.init_from_url('redis://:password@localhost:6379/0')
The redis url in your code could be dev url or whatever, the final redis auth config will be REDISCLI_URL
and REDISCLI_AUTH
in redis-auth-conf-secret
.
get_redis()
returns shared Redis instance Based on how you init redis_cli, could be normal Redis, master Redis or slave Redis of sentinel.
from redis_cli import get_redis
r = get_redis()
r.set('foo', 'bar')
r.get('foo')
r.delete('foo')
FAQs
A Redis Python Client
We found that redis-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.