Redis SET Command Not Working on Any Database Except the Default - redis

I'm experiencing an issue were writes to any other DB except the default DB at index 0 aren't working. Below is a snapshot of using redis-cli to create a key in the default DB, which is successful. I then switch to DB 1 and run the same SET command, but then when trying to GET they key, it returns (nil), and when listing the key with the KEYS command, it returns (empty list or set). The same behavior occurs with any DB greater than 0.
This issue has only recently started occurring. I've been using DB 1 for quite a while with no issues. The server in the example below is the master of a set of three servers being managed with Sentinel.
redisprod01:6379> set testkey "test"
OK
redisprod01:6379> get testkey
"test"
redisprod01:6379> keys testkey
1) "testkey"
redisprod01:6379> select 1
OK
redisprod01:6379[1]> set testkey "test"
OK
redisprod01:6379[1]> get testkey
(nil)
redisprod01:6379[1]> keys testkey
(empty list or set)
Here's the output of the INFO command:
# Server
redis_version:2.8.4
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:a44a05d76f06a5d9
redis_mode:standalone
os:Linux 3.16.0-30-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.2
process_id:5172
run_id:c23834afdaf0e113f4cca368be9e88881fa82c91
tcp_port:6379
uptime_in_seconds:7762453
uptime_in_days:89
hz:10
lru_clock:567194
config_file:/etc/redis/redis.conf
# Clients
connected_clients:1176
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:2000000696
used_memory_human:1.86G
used_memory_rss:2173636608
used_memory_peak:2003080696
used_memory_peak_human:1.87G
used_memory_lua:33792
mem_fragmentation_ratio:1.09
mem_allocator:jemalloc-3.4.1
# Persistence
loading:0
rdb_changes_since_last_save:17067
rdb_bgsave_in_progress:0
rdb_last_save_time:1536592844
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:5
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
# Stats
total_connections_received:2617247
total_commands_processed:1810758972
instantaneous_ops_per_sec:1207
rejected_connections:0
sync_full:2
sync_partial_ok:0
sync_partial_err:2
expired_keys:2190259
evicted_keys:128303561
keyspace_hits:456747821
keyspace_misses:421644916
pubsub_channels:2
pubsub_patterns:0
latest_fork_usec:54236
# Replication
role:master
connected_slaves:2
slave0:ip=10.93.109.123,port=6379,state=online,offset=2166765462577,lag=0
slave1:ip=10.93.109.122,port=6379,state=online,offset=2166765336151,lag=0
master_repl_offset:2166765934628
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2166764886053
repl_backlog_histlen:1048576
# CPU
used_cpu_sys:59513.46
used_cpu_user:50583.63
used_cpu_sys_children:25643.75
used_cpu_user_children:184819.30
# Keyspace
db0:keys=238726,expires=220772,avg_ttl=83043319
Heres the config:
1) "dbfilename"
2) "dump.rdb"
3) "requirepass"
4) ""
5) "masterauth"
6) ""
7) "unixsocket"
8) ""
9) "logfile"
10) "/var/log/redis/redis.log"
11) "pidfile"
12) "/var/run/redis/redis-server.pid"
13) "maxmemory"
14) "2000000000"
15) "maxmemory-samples"
16) "3"
17) "timeout"
18) "0"
19) "tcp-keepalive"
20) "0"
21) "auto-aof-rewrite-percentage"
22) "100"
23) "auto-aof-rewrite-min-size"
24) "67108864"
25) "hash-max-ziplist-entries"
26) "512"
27) "hash-max-ziplist-value"
28) "64"
29) "list-max-ziplist-entries"
30) "512"
31) "list-max-ziplist-value"
32) "64"
33) "set-max-intset-entries"
34) "512"
35) "zset-max-ziplist-entries"
36) "128"
37) "zset-max-ziplist-value"
38) "64"
39) "lua-time-limit"
40) "5000"
41) "slowlog-log-slower-than"
42) "10000"
43) "slowlog-max-len"
44) "1024"
45) "port"
46) "6379"
47) "databases"
48) "16"
49) "repl-ping-slave-period"
50) "10"
51) "repl-timeout"
52) "60"
53) "repl-backlog-size"
54) "1048576"
55) "repl-backlog-ttl"
56) "3600"
57) "maxclients"
58) "10000"
59) "watchdog-period"
60) "0"
61) "slave-priority"
62) "100"
63) "min-slaves-to-write"
64) "0"
65) "min-slaves-max-lag"
66) "10"
67) "hz"
68) "10"
69) "no-appendfsync-on-rewrite"
70) "no"
71) "slave-serve-stale-data"
72) "yes"
73) "slave-read-only"
74) "yes"
75) "stop-writes-on-bgsave-error"
76) "yes"
77) "daemonize"
78) "yes"
79) "rdbcompression"
80) "yes"
81) "rdbchecksum"
82) "yes"
83) "activerehashing"
84) "yes"
85) "repl-disable-tcp-nodelay"
86) "no"
87) "aof-rewrite-incremental-fsync"
88) "yes"
89) "appendonly"
90) "no"
91) "dir"
92) "/var/lib/redis"
93) "maxmemory-policy"
94) "allkeys-lru"
95) "appendfsync"
96) "everysec"
97) "save"
98) "900 1 300 10 60 10000"
99) "loglevel"
100) "notice"
101) "client-output-buffer-limit"
102) "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
103) "unixsocketperm"
104) "0"
105) "slaveof"
106) ""
107) "notify-keyspace-events"
108) ""
109) "bind"
110) "10.93.109.121"

select command is not supported for redis cluster. Did you recently transition from standalone redis to clustered redis ? Reference: https://redis.io/commands/select

This is running locally, but rather than using redis-cli SELECT 1, I ran redis-cli -n 1. Once I did that I was able set keys and retrieve them successfully on that database.
Switching between multiple databases that way seems to have done the trick for me.
Bear in mind that is running on my local machine.

Related

Is there any way to mapping point between 2 ecliptic curve?

The ecliptic curve E1: y^2 = x^3+7 over F17 with the base point G is (15, 13)
and the second ecliptic curve E2: y^2 = x^3+7 over F31 with the same base point G is (15, 13).
My question is: is there any way to calculate the equivalent point of F31 based on F17?
For example: with 7G = (10, 15) of curve F17, how to calculate 7G of F31 ? The result should be 7G = (12, 14) on F31.
Below is all points of two curves:
#----Curve F17-------#
1G = (15, 13)
2G = (2, 10)
3G = (8, 3)
4G = (12, 1)
5G = (6, 6)
6G = (5, 8)
7G = (10, 15)
8G = (1, 12)
9G = (3, 0)
10G = (1, 5)
11G = (10, 2)
12G = (5, 9)
13G = (6, 11)
14G = (12, 16)
15G = (8, 14)
16G = (2, 7)
17G = (15, 4)
#----Curve F31-------#
1G = (15, 13)
2G = (29, 17)
3G = (1, 22)
4G = (20, 19)
5G = (21, 17)
6G = (23, 23)
7G = (12, 14)
8G = (11, 27)
9G = (25, 22)
10G = (7, 19)
11G = (27, 27)
12G = (5, 9)
13G = (0, 24)
14G = (4, 12)
15G = (22, 23)
16G = (3, 13)
17G = (13, 18)
18G = (17, 23)
19G = (24, 4)
20G = (24, 27)
21G = (17, 8)
22G = (13, 13)
23G = (3, 18)
24G = (22, 8)
25G = (4, 19)
26G = (0, 7)
27G = (5, 22)
28G = (27, 4)
29G = (7, 12)
30G = (25, 9)
31G = (11, 4)

Is there a way to only HGETALL values in a hash larger than an int in Redis with Lua?

I'm trying to only get values in a hash larger than, say 1800, by Lua. I am new to Lua and I am not sure how to get the values from Redis, because the redis.call() method returns 1 only.
Here is my code. Here the keys of my hash is "1""2""3" etc, just to make it simpler.
for i=1,length do
value = tonumber(redis.call("HGET", KEYS[1], i))
if value >= 1800 then
return redis.call("HGET", KEYS[1], i)
end
end
Let's say I have a hash called Data like this:
HGETALL Data
1) "monday"
2) "1802"
3) "tuesday"
4) "1283"
5) "wednesday"
6) "3487"
7) "thursday"
8) "1899"
9) "friday"
10) "1709"
11) "saturday"
12) "1909"
13) "sunday"
14) "1799"
I expect that when I use the HGETALL method, I get this:
1) "monday"
2) "1802"
5) "wednesday"
6) "3487"
7) "thursday"
8) "1899"
11) "saturday"
12) "1909"
for i=1,length do
value = tonumber(redis.call("HGET", KEYS[1], i))
if value >= 1800 then
return redis.call("HGET", KEYS[1], i)
end
end
This code tells your computer: look through all entries and give me the first one that is >= 1802.
If you want to get all values above you have several options.
You get a full list of entries using HGETALL and then filter the returned list of entries or you get single elements and put them into a list when they are >= 1800.
The return statement is used to return values from a function or a
chunk (which is an anonymous function).
That means whatever function you're code is in will end if you return.
So using it inside your loop is not really an option if you want to process multiple entries.
Try something like
-- create an empty table
local greatValues = {}
for i=1,length do
value = tonumber(redis.call("HGET", KEYS[1], i))
if value >= 1800 then
-- insert any value that is >=1800 into the table
table.insert(greatValues, value)
end
end
-- return the list of results
return greatValues

SRSS Switch with filter keeps throwing error

I've been trying to adjust this multiple times thinking that my null checks are broken. Referenced a null check form here: IIF Statement Null Check
That did nto seem to work for my case. Anyway, if anyone could take a quick look and see if they can see the mistake that would be great.
=SWITCH(
Fields!lmItemStatus.Value, "Additional Repair Proposal Submitted - Pending Award", Year(DateAdd(DateInterval.Day, (Fields!lmFinalDelvTerms.Value + 60), Today)),
Fields!lmItemStatus.Value, "Repair Award*", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 90), Today)),
Fields!lmItemStatus.Value, "Award Received - Pending Shipment For Assessment" & Fields!vendor.Value, "H" or "I", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 90), Fields!lmiiiSAAwardDate.Value)),
Fields!lmItemStatus.Value, "Award Received - Pending Shipment For Assessment" & Fields!vendor.Value, "A" or "B" or "C" or "D" or "E" or "F" or "G", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 30), Fields!lmiiiSAAwardDate.Value)),
Fields!lmItemStatus.Value, "Undergoing Assessment at Repair Facility", Year(DateAdd(DateInterval.Day, (Fields!lmArmaDelvTerms.Value + fields!lmFinalDelvTerms.Value + 30), Fields!lmVendorStartDateAssess.Value)),
Fields!lmItemStatus.Value, "Assessment Complete - Pending Action", Year(DateAdd(DateInterval.Day, (Fields!lmFinalDelvTerms.Value + 60), Fields!lmAssessCompleteDate.Value)),
Fields!lmItemStatus.Value, "Final Repair Awarded" and Not(IsNothing(Fields!EstDelivDate.Value)), Year(Fields!EstDelivDate.Value),
Fields!lmItemStatus.Value, "Final Repair Awarded" and IsNothing(Fields!EstDelivDate.Value), Year(Fields!lmFinalDelvTerms.Value + 30), Today)
The error I keep getting is a conversion error From "Lom" to type "Long" is nto valid.
Your syntax is wrong. The Switch function takes pairs of arguments. These need to be an expression that evaluates to true or false and the second is the result if it's true. So it should look like this:
=Switch(Fields!lmItemStatus.Value = "Additional Repair Proposal Submitted - Pending Award"
, Year(DateAdd(DateInterval.Day, (Fields!lmFinalDelvTerms.Value + 60), Today))
, ...)
Figured it out- there were multiple errors inside my code. In line
Fields!lmItemStatus.Value = "Award Received - Pending Shipment For Assessment" & Fields!vendor.Value, "A" or "B" or "C" or "D" or "E" or "F" or "G", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 30), Fields!lmiiiSAAwardDate.Value)),
I did not realize I could not actually use a "or" or "and" inside of a switch. I had to split this into a separate switch for each string ie:
Fields!lmItemStatus.Value = "Award Received - Pending Shipment For Assessment" & Fields!vendor.Value = "A", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 30), Fields!lmiiiSAAwardDate.Value)),
Fields!lmItemStatus.Value = "Award Received - Pending Shipment For Assessment" & Fields!vendor.Value = "B", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 30), Fields!lmiiiSAAwardDate.Value)),
Also I was trying to parse the dates out. I did not need to do that.

If with multiple and & or

I've been trying to run the below IF condition, however it does not work as intended:
If (LandscapingDataRange(MailCounter, 6) = 1 And (LandscapingDataRange(MailCounter, 4) = 0 Or LandscapingDataRange(MailCounter, 5) = 0)) _
Or (LandscapingDataRange(MailCounter, 6) = 1 And ((LandscapingDataRange(MailCounter, 4) - LandscapingDataRange(MailCounter, 7)) / LandscapingDataRange(MailCounter, 4)) > 0.1) _
Or (LandscapingDataRange(MailCounter, 6) = 0 And LandscapingDataRange(MailCounter, 5) > 0) _
Or (0 < LandscapingDataRange(MailCounter, 6) < 1 And (LandscapingDataRange(MailCounter, 4) = 0 Or LandscapingDataRange(MailCounter, 5) = 0)) _
Or (0 < LandscapingDataRange(MailCounter, 6) < 1 And ((LandscapingDataRange(MailCounter, 4) - LandscapingDataRange(MailCounter, 7)) / LandscapingDataRange(MailCounter, 4)) > 0.1) Then
Those rows with 0 in (LandscapingDataRange(MailCounter, 6)
and 0 in LandscapingDataRange(MailCounter, 5)
Are still applied in the IF function.
I would take a guess that you are using Or where you should be using ElseIf and so your logic is wrong. In that case, use Select Case instead - it's quicker and cleaner. Here's an example with the first 3 conditions and an Else clause - just add the other conditions as required.
Select Case True
(LandscapingDataRange(MailCounter, 6) = 1 And (LandscapingDataRange(MailCounter, 4) = 0 Or LandscapingDataRange(MailCounter, 5) = 0))
'// Do Something
(LandscapingDataRange(MailCounter, 6) = 1 And ((LandscapingDataRange(MailCounter, 4) - LandscapingDataRange(MailCounter, 7)) / LandscapingDataRange(MailCounter, 4)) > 0.1)
'// Do Something
(LandscapingDataRange(MailCounter, 6) = 0 And LandscapingDataRange(MailCounter, 5) > 0)
'// Do Something
Case Else
'// Do Something if none of the criteria are met.
End Select
I don't get, what you want to achieve, but logic operator have an order, in which they are resolved, just like multiplication/division before addition/substraction.
Maybe that is the problem in your case. Before any Or is computed, all And are resolved. So you have to use brackets, if this isn't the order, you want it to be computed.
The precedence order in Visual Basic is Not before And before Or before Xor, and the same rules should apply to VBA too.

3 way check box (toggle)

I have a custom 'toggle' (using ButterscotchTheme) and I am trying to add a 3rd option.
This is how it currently is: (cant post pictures due to being new, but here is links to the pictures)
I would like a third option. I have checked the theme code and it is done by Checkbox rules. And I know a Tricheckbox is a thing, I am just unsure how to get it to work. I did some research and was unable to figure it out in this situation.
Here is all the Themes toggle code:
Public Class ButterscotchToggle : Inherits Control
Private _check As Boolean
Public Property Checked As Boolean
Get
Return _check
End Get
Set(ByVal value As Boolean)
_check = value
Invalidate()
End Set
End Property
Sub New()
MyBase.New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
DoubleBuffered = True
BackColor = Color.Transparent
Size = New Size(80, 25)
End Sub
Protected Overrides Sub OnClick(ByVal e As EventArgs)
Checked = Not Checked
MyBase.OnClick(e)
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim b As Bitmap = New Bitmap(Width, Height)
Dim g As Graphics = Graphics.FromImage(b)
Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
Dim maininnerrect As Rectangle = New Rectangle(7, 7, Width - 15, Height - 15)
Dim buttonrect As New LinearGradientBrush(outerrect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), 90S)
MyBase.OnPaint(e)
g.Clear(BackColor)
g.SmoothingMode = SmoothingMode.HighQuality
g.InterpolationMode = InterpolationMode.HighQualityBicubic
g.FillPath(New SolidBrush(Color.FromArgb(40, 37, 33)), RoundRect(outerrect, 5))
g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(outerrect, 5))
g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(maininnerrect, 3))
g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(maininnerrect, 3))
If Checked Then
g.FillPath(buttonrect, RoundRect(New Rectangle(3, 3, CInt((Width / 2) - 3), Height - 7), 7))
g.DrawString("ON", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(2, 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
Else
g.FillPath(buttonrect, RoundRect(New Rectangle(CInt((Width / 2) - 3), 3, CInt((Width / 2) - 3), Height - 7), 7))
g.DrawString("OFF", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(CInt((Width / 2) - 2), 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
End If
e.Graphics.DrawImage(b, New Point(0, 0))
g.Dispose() : b.Dispose()
End Sub
End Class
Any help would be greatly appreciated!
Theme downloaded from Butterscotch Theme GDI+
You would have to change that boolean property to an integer (or even better, create an enum):
Private _check As Integer
Public Property Checked As Integer
Get
Return _check
End Get
Set(ByVal value As Integer)
_check = value
Invalidate()
End Set
End Property
Change the OnClick behavior:
Protected Overrides Sub OnClick(ByVal e As EventArgs)
If Checked + 1 > 2 Then
Checked = 0
Else
Checked += 1
End If
MyBase.OnClick(e)
End Sub
and then adjust the drawing accordingly (placing the third option in the middle I'm guessing):
Select Case Checked
Case 0
g.FillPath(buttonrect, RoundRect(New Rectangle(CInt((Width / 2) - 3), 3, CInt((Width / 2) - 3), Height - 7), 7))
g.DrawString("OFF", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(CInt((Width / 2) - 2), 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
Case 1
g.FillPath(buttonrect, RoundRect(New Rectangle(3, 3, CInt((Width / 2) - 3), Height - 7), 7))
g.DrawString("ON", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(2, 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
Case 2
g.FillPath(buttonrect, RoundRect(New Rectangle((Width / 2) - (Width / 4), 3, CInt((Width / 2) - 3), Height - 7), 7))
g.DrawString("???", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle((Width / 2) - (Width / 4), 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
End Select