mirror of
https://github.com/fluencelabs/redis
synced 2025-04-12 20:26:04 +00:00
Cluster: Tcl cluster client: slots-nodes map and close method.
Now the client is able to actually run commands in a Redis Cluster assuming the slots->nodes map is stable.
This commit is contained in:
parent
5344357f80
commit
fcd2065f8e
@ -109,6 +109,7 @@ proc ::redis_cluster::__method__refresh_nodes_map {id} {
|
|||||||
port $port \
|
port $port \
|
||||||
flags $flags \
|
flags $flags \
|
||||||
slaveof $slaveof \
|
slaveof $slaveof \
|
||||||
|
slots $slots \
|
||||||
link $link \
|
link $link \
|
||||||
]
|
]
|
||||||
dict set nodes $addr $node
|
dict set nodes $addr $node
|
||||||
@ -116,11 +117,33 @@ proc ::redis_cluster::__method__refresh_nodes_map {id} {
|
|||||||
|
|
||||||
set ::redis_cluster::nodes($id) $nodes
|
set ::redis_cluster::nodes($id) $nodes
|
||||||
|
|
||||||
# TODO: Populates the slots -> nodes map.
|
# Populates the slots -> nodes map.
|
||||||
dict for {addr node} $nodes {
|
dict for {addr node} $nodes {
|
||||||
puts "$addr -> $node"
|
foreach slotrange [dict get $node slots] {
|
||||||
|
lassign [split $slotrange -] start end
|
||||||
|
if {$end == {}} {set end $start}
|
||||||
|
for {set j $start} {$j <= $end} {incr j} {
|
||||||
|
dict set ::redis_cluster::slots($id) $j $addr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Free a redis_cluster handle.
|
||||||
|
proc ::redis_cluster::__method__close {id} {
|
||||||
|
catch {
|
||||||
|
set nodes $::redis_cluster::nodes($id)
|
||||||
|
dict for {addr node} $nodes {
|
||||||
|
catch {
|
||||||
|
[dict get $node link] close
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {unset ::redis_cluster::startup_nodes($id)}
|
||||||
|
catch {unset ::redis_cluster::nodes($id)}
|
||||||
|
catch {unset ::redis_cluster::slots($id)}
|
||||||
|
catch {interp alias {} ::redis_cluster::instance$id {}}
|
||||||
|
}
|
||||||
|
|
||||||
proc ::redis_cluster::__dispatch__ {id method args} {
|
proc ::redis_cluster::__dispatch__ {id method args} {
|
||||||
if {[info command ::redis_cluster::__method__$method] eq {}} {
|
if {[info command ::redis_cluster::__method__$method] eq {}} {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user