I am trying to connect to a remote redis server and set keys using HSET command like below
hset ABCD:1105 balance 1000
I can able to see the Key using KEYS *
But after approx 1 minute the KEYS * returns empty (empty list or set) . Whereas TTL on the key returns -1.
This is the memory configuration in the redis server
1) "masterauth"
2) ""
3) "maxmemory"
4) "0"
5) "maxmemory-samples"
6) "5"
7) "maxclients"
8) "10000"
9) "min-slaves-to-write"
10) "0"
11) "min-replicas-to-write"
12) "0"
13) "min-slaves-max-lag"
14) "10"
15) "min-replicas-max-lag"
16) "10"
17) "maxmemory-policy"
18) "noeviction"
Here the max memory policy is also noeviction. Then why the Keys are getting expired.
Updating the logs of redis server pod
> 1:C 09 Jan 2021 17:02:04.495 # oO0OoO0OoO0Oo Redis is starting
> oO0OoO0OoO0Oo 1:C 09 Jan 2021 17:02:04.495 # Redis version=5.0.7,
> bits=64, commit=00000000, modified=0, pid=1, just started 1:C 09 Jan
> 2021 17:02:04.495 # Configuration loaded 1:M 09 Jan 2021 17:02:04.496
> * Running mode=standalone, port=6379. 1:M 09 Jan 2021 17:02:04.496 # WARNING: The TCP backlog setting of 511 cannot be enforced because
> /proc/sys/net/core/somaxconn is set to the lower value of 128. 1:M 09
> Jan 2021 17:02:04.496 # Server initialized 1:M 09 Jan 2021
> 17:02:04.496 # WARNING you have Transparent Huge Pages (THP) support
> enabled in your kernel. This will create latency and memory usage
> issues with Redis. To fix this issue run the command 'echo never >
> /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to
> your /etc/rc.local in order to retain the setting after a reboot.
> Redis must be restarted after THP is disabled. 1:M 09 Jan 2021
> 17:02:04.897 * DB loaded from append only file: 0.400 seconds 1:M 09
> Jan 2021 17:02:04.897 * Ready to accept connections
Update2 : Memory Info
used_memory:999576 used_memory_human:976.15K used_memory_rss:5341184
used_memory_rss_human:5.09M used_memory_peak:1679456
used_memory_peak_human:1.60M used_memory_peak_perc:59.52%
used_memory_overhead:958562 used_memory_startup:790256
used_memory_dataset:41014 used_memory_dataset_perc:19.59%
allocator_allocated:1104272 allocator_active:1642496
allocator_resident:5189632 total_system_memory:29508444160
total_system_memory_human:27.48G used_memory_lua:37888
used_memory_lua_human:37.00K used_memory_scripts:0
used_memory_scripts_human:0B number_of_cached_scripts:0 maxmemory:0
maxmemory_human:0B maxmemory_policy:noeviction
allocator_frag_ratio:1.49 allocator_frag_bytes:538224
allocator_rss_ratio:3.16 allocator_rss_bytes:3547136
rss_overhead_ratio:1.03
Related
My job is running every at the time specified but its running every second of time specified, for example if I set a job to run at 22:54 it will run every second from 22:54:00 until 22:54:59. I want it to just run once at the time specified...any help is much appreciated
my code:
#Scheduled(cron = "* 54 22 * * ?")
public void getCompaniess() {
System.out.println(new Date()+" > Running testScheduledMethod...");
}
output:
Thu Mar 12 22:54:00 GMT 2020 > Running testScheduledMethod...
Thu Mar 12 22:54:01 GMT 2020 > Running testScheduledMethod...
.....
Thu Mar 12 22:54:59 GMT 2020 > Running testScheduledMethod...
Change the first * to 0, with a star you are saying "every second".
Replacing it with a 0 (or any other number 0-59) will have it run on that "second" instead of "all of them".
#Scheduled(cron = "0 54 22 * * ?")
public void getCompaniess() {
System.out.println(new Date()+" > Running testScheduledMethod...");
}
I would like my watcher to run from Monday to Friday only. So I'm trying to use this schedule:
"trigger": {
"schedule" : { "cron" : "0 0 0/4 * * MON-FRI" }
},
"input": {
...
However, I'm getting
Error
Watcher: [parse_exception] could not parse [cron] schedule
when I'm trying to save the watcher. Removing MON-FRI does helps but I need it.
This expression works:
0 0 0/4 ? * MON-FRI
But I'm not sure I understand why ? is required for either the day_of_week or day_of_month
Thank you!
I believe this is what you are looking for:
"0 0 0/4 ? * MON-FRI"
You can use croneval to check your cron expressions 1:
$ /usr/share/elasticsearch/bin/x-pack/croneval "0 0 0/4 ? * MON-FRI"
Valid!
Now is [Mon, 20 Aug 2018 13:32:26]
Here are the next 10 times this cron expression will trigger:
1. Mon, 20 Aug 2018 09:00:00
2. Mon, 20 Aug 2018 13:00:00
3. Mon, 20 Aug 2018 17:00:00
4. Mon, 20 Aug 2018 21:00:00
5. Tue, 21 Aug 2018 01:00:00
6. Tue, 21 Aug 2018 05:00:00
7. Tue, 21 Aug 2018 09:00:00
8. Tue, 21 Aug 2018 13:00:00
9. Tue, 21 Aug 2018 17:00:00
10. Tue, 21 Aug 2018 21:00:00
For the first expression you'll get following java exception:
java.lang.IllegalArgumentException: support for specifying both a day-of-week AND a day-of-month parameter is not implemented.
You can also use Crontab guru to get human readable descriptions like:
At every minute past every 4th hour from 0 through 23 on every day-of-week from Monday through Friday.
The question mark means 'No Specific value'. From the documentation on Quartz's website:
? (“no specific value”) - useful when you need to specify something in one of the two fields in which the character is allowed, but not the other. For example, if I want my trigger to fire on a particular day of the month (say, the 10th), but don’t care what day of the week that happens to be, I would put “10” in the day-of-month field, and “?” in the day-of-week field. See the examples below for clarification.
http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html
I suppose since you want your schedule to run every 4 hours, mon-fri, the actual day of the month is irrelevant, so the ? specifies that. * on teh other hand would be 'all values' which would not make sense since you are specifying only mon-fri for day of the week.
Hope that helps!
I create a hash with months as keys and timelaps as values
biens_delai[bien_date.mon] = b.delai
I get this result without month parsing
{Wed, 18 Jan 2017=>3.0, Sat, 25 Feb 2017=>2.0, Fri, 17 Mar 2017=>3.0, Sat, 25 Mar 2017=>5.0, Tue, 18 Apr 2017=>2.0, Thu, 29 Jun 2017=>2.0}
In March i have 2 values but when i parse by month i get the most high value and i want a addition of 2 values for March not the most high
{1=>3.0, 2=>2.0, 3=>5.0, 4=>2.0, 6=>2.0}
That's not the high value which you are getting, the values are getting overwritten, try the following
biens_delai[bien_date.mon] = biens_delai[bien_date.mon].to_f + b.delai
I have an IMAP mail with a message string that looks like this:
message = #<Mail::Message:70152447148720, Multipart: false, Headers: <Return-Path: <apache#mail.gameseek.co.uk>>, <Received: by 10.86.68.12 with SMTP id q12cs352558fga; Mon, 9 Mar 2009 04:23:05 -0700 (PDT)>, <Received: by 10.210.137.14 with SMTP id k14mr2429643ebd.46.1236597783700; Mon, 09 Mar 2009 04:23:03 -0700 (PDT)>, <Received: from exproxy-2.exserver.dk (exproxy-2.exserver.dk [195.69.129.163]) by mx.google.com with ESMTP id 27si3500694ewy.75.2009.03.09.04.23.03; Mon, 09 Mar 2009 04:23:03 -0700 (PDT)>, <Received: by exproxy-2.exserver.dk (Postfix, from userid 65534) id DF2F6106EF3; Mon, 9 Mar 2009 12:13:26 +0100 (CET)>, <Received: from exsmtp01.exserver.dk (exsmtp01.exserver.dk [195.69.129.177]) by exproxy-2.exserver.dk (Postfix) with ESMTP id C2CEE106ED0 for <support_email.com#exfwd01.scannet.dk>; Mon, 9 Mar 2009 12:13:26 +0100 (CET)>, <Received: from exsmtp02.exserver.dk ([10.10.10.32]) by exsmtp01.exserver.dk with Microsoft SMTPSVC(6.0.3790.1830); Mon, 9 Mar 2009 12:22:19 +0100>, <Received: from front08.exserver.dk ([195.69.129.93]) by exsmtp02.exserver.dk with Microsoft SMTPSVC(6.0.3790.1830); Mon, 9 Mar 2009 12:22:19 +0100>, <Received: from localhost (front08.exserver.dk [127.0.0.1]) by front08.exserver.dk (Postfix) with ESMTP id F1B2BC4028 for <support#email.com>; Mon, 9 Mar 2009 12:46:22 +0100 (CET)>, <Received: from front08.exserver.dk ([127.0.0.1]) by localhost (front08.exserver.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mrYGo4G2pt13 for <support#email.com>; Mon, 9 Mar 2009 12:46:16 +0100 (CET)>, <Received: from mail.gameseek.co.uk (78.109.164.42.srvlist.ukfast.net [78.109.164.42]) by front08.exserver.dk (Postfix) with ESMTP id 99022C4021 for <support#email.com>; Mon, 9 Mar 2009 12:46:16 +0100 (CET)>, <Received: by mail.gameseek.co.uk (Postfix, from userid 48) id D321218DD2D; Mon, 9 Mar 2009 11:22:55 +0000 (GMT)>, <Date: Mon, 09 Mar 2009 11:22:55 +0000>, <From: myorder#gameseek.co.uk>, <Reply-To: myorder#gameseek.co.uk>, <To: support#email.com>, <Message-ID: <20090309112255.D321218DD2D#mail.gameseek.co.uk>>, <Subject: Gameseek Order Refunded: Gh68y1235386413>, <Delivered-To: my#email.com>, <Received-SPF: neutral (google.com: 195.69.129.163 is neither permitted nor denied by best guess record for domain of apache#mail.gameseek.co.uk) client-ip=195.69.129.163;>, <Authentication-Results: mx.google.com; spf=neutral (google.com: 195.69.129.163 is neither permitted nor denied by best guess record for domain of apache#mail.gameseek.co.uk) smtp.mail=apache#mail.gameseek.co.uk>, <X-Exserver-To: support_email.com#exfwd01.scannet.dk>, <X-Virus-Scanned: amavisd-new at exserver.dk>, <X-OriginalArrivalTime: 09 Mar 2009 11:22:19.0838 (UTC) FILETIME=[4F6005E0:01C9A0A9]>, <X-ScanNet-Forward: TTL=5>>
I now wish to give it a proper encoding:
unless message.multipart?
charset = message.charset # => "UTF-8"
if charset != nil
body = message.body.decoded.force_encoding(charset).encode("UTF-8") # => "\n\nHello you,\n\nYour order or part of it has been refunded by Gameseek. The refund will be present on the same payment method you used when purchasing. If no other items are due to be posted to you the postage charge will also be refunded.\n\nPlease allow upto four working days for this refund to process.\n\nIf you have not contacted us about this order then it is most likely you are being refunded for an item we cannot currently get hold of.\n\nWe do apologise if this is the case, we would rather refund customers rather than having them wait weeks and weeks for an item.\n\nIf you have contacted us about this order then you will know why you are being refunded.\nMay we apologise if we have not met your requirements on this occassion.\n\nYour Order: Product | Category | Quantity | Cost\n---------------------------------------------------\nDragon Ball Z - Supersonic Warriors 2 | NintendoDS | 1 | \xA326.97\n\n\nFor all order enquires please contact myorder#gameseek.co.uk\n\nThank you for using Gameseek.\n"
end
end
body = body.split(/Sent from my iPhone/)[0]
The last line raises the following error:
invalid byte sequence in UTF-8
Any idea how to fix this?
The text contains the invalid sequence \xA3. This represents a pound sign in Latin-1 (ISO-8859-1).
"\xA3".force_encoding('ISO-8859-1').encode('UTF-8')
#=> "£"
The quick fix is to replace invalid byte sequences in body with String#scrub, but that will remove them:
"\xA326.97".scrub('')
#=> "26.97"
However, to solve the "real" problem you should look earlier in the pipeline. The supplied charset seems to be wrong. Apparently the message is encoded in Latin-1, although the charset suggests something different. Maybe the problem is on the side of the sender.
In Ruby 1.8.7, how to set the time zone of a time?
In the following examples, my system time zone is PST (-8:00 hours from UTC)
Given a time (21 Feb 2011, 20:45), presume that the time is in EST:
#this interprets the time as system time zone, i.e. PST
Time.local(2011,02,21,20,45)
#=> Mon Feb 21 20:45:00 -0800 2011
#this **converts** the time into EST, which is wrong!
Time.local(2011,02,21,20,45).in_time_zone "Eastern Time (US & Canada)"
#=> Mon, 21 Feb 2011 23:45:00 EST -05:00
But, the output I want is:
Mon Feb 21 20:45:00 -0500 2011 (Note the -0500 (EST) as opposed to -0800 (PST) and the hour is same, i.e. 20, not 23)
UPDATE (see the better version of this below)
I managed to get this to work, but I don't like it:
DateTime.new(2011,02,21,20,45).change :offset => -(300.0 / 1440.0)
# => Mon, 21 Feb 2011 20:45:00 +0500
Where
300 = 5 hrs x 60 minutes
1440 = number of minutes in a day
or the "right" way:
DateTime.civil(2011,02,21,20,45,0,Rational(-5, 24))
Question: Now, is there a way to determine the accurate(i.e. catering for daylight saving time etc) UTC offset from Time.zone so that I can pass it to the change method?
Reference: DateTime::change method
UPDATE (better version)
Thanks to #ctcherry for all the help!
Determine the accurate time zone info from Time.zone:
DateTime.civil(2011,02,21,20,45,0,Rational((Time.zone.tzinfo.current_period.utc_offset / 3600), 24))
In ruby 1.8.7 it doesn't appear to be very easy to do what are asking for according to the documentation:
http://www.ruby-doc.org/core-1.8.7/classes/Time.html
However in 1.9 it looks a lot easier by passing the timezone offset to the localtime() method on a Time object:
http://www.ruby-doc.org/core/classes/Time.html#M000346
UPDATE
The offset for Time.zone is easy since its an object on its own: (This is in a Rails console)
ruby-1.8.7-p248 :001 > Time.zone
=> #<ActiveSupport::TimeZone:0x103150190 #current_period=nil, #name="Central Time (US & Canada)", #tzinfo=#<TZInfo::TimezoneProxy: America/Chicago>, #utc_offset=nil>
ruby-1.8.7-p248 :002 > Time.zone.utc_offset
=> -21600
ruby-1.8.7-p248 :003 > Time.zone.formatted_offset
=> "-06:00"
So I think this will (almost) accomplish what you want:
require 'time'
t = "21 Feb 2011, 20:45"
Time.parse(t) # => Mon Feb 21 20:45:00 -0700 2011
t += " -05:00" # this is the trick
Time.parse(t) # => Mon Feb 21 18:45:00 -0700 2011
It still returns the time based on your system time zone, but the actual time is the correct time that you are seeking.
By the way, this is tested on 1.8.7-p334.