Coder Social home page Coder Social logo

redistick's Introduction

RediStick

CI

A Redis client for Pharo using Stick auto-reconnection layer

Many parts are borrowed from RedisClient.

However RediStick use Stick for supporting auto reconnection.

Installation

Default (Core only):

Metacello new
  baseline: 'RediStick';
  repository: 'github://mumez/RediStick/repository';
  load.

With Connection-Pool package:

Metacello new
  baseline: 'RediStick';
  repository: 'github://mumez/RediStick/repository';
  load: #('Core' 'ConnectionPool').

With Pubsub package:

Metacello new
  baseline: 'RediStick';
  repository: 'github://mumez/RediStick/repository';
  load: #('Core' 'Pubsub').

With Stream package:

Metacello new
  baseline: 'RediStick';
  repository: 'github://mumez/RediStick/repository';
  load: #('Core' 'Stream').

With Search package:

Metacello new
  baseline: 'RediStick';
  repository: 'github://mumez/RediStick/repository';
  load: #('Core' 'Search').

Sample Code

Basic usage

stick := RsRediStick targetUrl: 'sync://localhost'.
stick connect.

stick beSticky. "Auto reconnect when server is not accessible"
stick beSwitchy: 'sync://otherhost'. "Or connect to the secondary server"
stick onError: [ :e | e pass ]. "Or just pass an error (not reconnect) - mainly for debug"

stick endpoint info.
stick endpoint get: 'a'.
stick endpoint set: 'a' value: 999.

Using a connection pool with a wrapper class

RsRedisConnectionPool primaryUrl: 'sync://localhost:6379'.
redis := RsRedisProxy of: #client1.
redis at: 'a'.
redis at: 'a' put: 999.

In this example, the default connection pool is implicitly used through RedisProxy.

Using Pubsub channel

RediStick provides a channel class for using redis pubsub API very easily.

Please read Pubsub.md.

Using Stream

RediStick supports Redis Streams - distributed event streaming API.

(Basic usage will be documented soon).

Using Search

RediStick supports RediSearch - a full-text search extension for Redis.

Please read Search.md.

redistick's People

Contributors

cafekrem avatar mumez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

cafekrem

redistick's Issues

typo error on RsConnectionPool

my bad I did a typo error

createStickAt: key
	"override"

	| stick |
	stick := RsRediStick targetUrl: self primaryUrl.
	stick beSticky.
	stick username: self userName password: self password.
	stick connect.
	^ stick

stick username: self userName password: self password. should be stick userName: self userName password: self password.

PR will come

Understanding PubSub case

On Pharo 11 on macOS.

When trying to use the RediStick PUBSUB feature at a basic level I've ran the following snippets which do not end up printing "Hello" in the Transcript as I'd expect. Shouldn't that work?

Metacello new
  baseline: 'RediStick';
  repository: 'github://mumez/RediStick/repository';
  load: #('Core' 'ConnectionPool' 'Pubsub' ).

RsRedisConnectionPool primaryUrl: 'sync://localhost:6379'.
redis := RsRedisProxy of: #client1.
redis at: 'a'.
redis at: 'a' put: 999.

redis
channel := #greeting.
channels := { channel }.

onMessage := [ :msg | Transcript crShow: msg ].
redis endpoint subscribe: channels callback: onMessage.

redis numberOfSubscribers: channels. 
"nil"

content := 'Hello'.
redis endpoint publish: #greeting message: (STONJSON toString: content). "nil"

redis endpoint unsubscribe: channels. 
"RsRedisEndpoint(localhost:6379)"
Screen Shot 2024-01-31 at 12 13 26

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.