cache-flow 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/lib/cache_flow.rb +27 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YTNlY2Q1MGE1NjVmNTJmNzA5Y2ZiNjQ5YmE3ODgzNzhlNzE3M2RmMw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MjMwOTBlNmQxMWJlZWU1NjZlMzBjNGU4OWQ2NzE4OWY4YjA4MDNjZA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDZkYjQxNDNlN2Q4ZTk2NGJiZjc5ZmYwNGRiZThjNjg4MmU0YjdjZjdjNDdl
|
10
|
+
ZmVlNjZiZjBhMjRlMTU4M2Y2ODI3YjFkMWYwMzMwOGJjNmNjZWNlYzRhNmQ3
|
11
|
+
NWExMDkxNmExZmM4NjliNWRkNmRjY2E2Y2MxYmEyNTdmNGRhZDQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YjY2NGJiMTM4MzQ1YmYzYjIyOTFmMDA2MzdmMzdhZmNkNzMzNjBlNzZkZTAx
|
14
|
+
MTJiOTEwMzkyODUxOTQyNzBkNWU3NTdlMTllZWM1YzBiNjBmMmUzMzg3OWYy
|
15
|
+
Nzk0NDBiM2MwYWE4ZDkxM2ZjZjM4NWQ0MGNiZDQ2ZDJmNDQ2YmU=
|
data/lib/cache_flow.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class CacheFlow
|
2
|
+
# Put all these constants into a configurable setting hash
|
3
|
+
TIME_ZONE = "Pacific Time (US & Canada)"
|
4
|
+
# Hour based on 24 hour clock
|
5
|
+
HOUR_RANGE_START = 1
|
6
|
+
HOUR_RANGE_END = 4
|
7
|
+
attr_accessor :frequency
|
8
|
+
|
9
|
+
def initialize(frequency = "daily")
|
10
|
+
self.frequency = frequency
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate_expiry
|
14
|
+
# Rails :expires_in accepts seconds from now to expire the key in
|
15
|
+
case frequency
|
16
|
+
when "daily"
|
17
|
+
random_time_in_range(24.hours.from_now)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def random_time_in_range(day_to_bust)
|
22
|
+
time_to_bust = day_to_bust.in_time_zone(TIME_ZONE).beginning_of_day
|
23
|
+
range_start = time_to_bust + HOUR_RANGE_START.hours
|
24
|
+
range_end = time_to_bust + HOUR_RANGE_END.hours
|
25
|
+
rand(range_start.to_i..range_end.to_i) - Time.now.to_i
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cache-flow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dan DeMeyere
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: business_time
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
41
|
+
description: Define a window of time to have all your cache expire randomly within.
|
42
|
+
email: dan.demeyere@gmail.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/cache_flow.rb
|
48
|
+
homepage: https://github.com/dandemeyere/cache-flow
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 2.2.2
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: A gem to manage when your cache expires.
|
72
|
+
test_files: []
|