litestack 0.1.5 → 0.1.7

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.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: litestack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohamed Hassan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-27 00:00:00.000000000 Z
11
+ date: 2023-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -72,7 +72,6 @@ files:
72
72
  - lib/active_job/queue_adapters/ultralite_adapter.rb
73
73
  - lib/active_record/connection_adapters/litedb_adapter.rb
74
74
  - lib/active_support/cache/litecache.rb
75
- - lib/active_support/cache/ultralite_cache_store.rb
76
75
  - lib/litestack.rb
77
76
  - lib/litestack/litecache.rb
78
77
  - lib/litestack/litedb.rb
@@ -83,6 +82,7 @@ files:
83
82
  - lib/litestack/version.rb
84
83
  - lib/railties/rails/commands/dbconsole.rb
85
84
  - lib/sequel/adapters/litedb.rb
85
+ - lib/sequel/adapters/shared/litedb.rb
86
86
  - samples/ultrajob.yaml
87
87
  homepage: http://github.com/oldmoe/litestack
88
88
  licenses:
@@ -1,100 +0,0 @@
1
- require "delegate"
2
- require "active_support/core_ext/enumerable"
3
- require "active_support/core_ext/array/extract_options"
4
- require "active_support/core_ext/numeric/time"
5
- require "active_support/cache"
6
- require_relative '../../ultralite/cache.rb'
7
-
8
-
9
- module ActiveSupport
10
- module Cache
11
- class UltraliteCacheStore < Store
12
-
13
- #prepend Strategy::LocalCache
14
-
15
- def self.supports_cache_versioning?
16
- true
17
- end
18
-
19
- def initialize(options={})
20
- super
21
- @options[:return_full_record] = true
22
- @cache = ::Ultralite::Cache.new(@options)
23
- end
24
-
25
- def increment(key, amount = 1, options = nil)
26
- key = key.to_s
27
- options = merged_options(options)
28
- @cache.transaction(:immediate) do
29
- if value = read(key, options)
30
- value = value.to_i + amount
31
- write(key, value, options)
32
- end
33
- end
34
- end
35
-
36
- def decrement(key, amount = 1, options = nil)
37
- options = merged_options(options)
38
- increment(key, -1 * amount, options[:expires_in])
39
- end
40
-
41
- def prune(limit = nil, time = nil)
42
- @cache.prune(limit)
43
- end
44
-
45
- def cleanup(limit = nil, time = nil)
46
- @cache.prune(limit)
47
- end
48
-
49
- def clear()
50
- @cache.clear
51
- end
52
-
53
- def count
54
- @cache.count
55
- end
56
-
57
- def size
58
- @cache.size
59
- end
60
-
61
- def max_size
62
- @cache.max_size
63
- end
64
-
65
- def stats
66
- @cache.stats
67
- end
68
-
69
- private
70
-
71
- # Read an entry from the cache.
72
- def read_entry(key, **options)
73
- deserialize_entry(@cache.get(key))
74
- end
75
-
76
- # Write an entry to the cache.
77
- def write_entry(key, entry, **options)
78
- write_serialized_entry(key, serialize_entry(entry, **options), **options)
79
- end
80
-
81
- def write_serialized_entry(key, payload, **options)
82
- expires_in = options[:expires_in].to_i
83
- if options[:race_condition_ttl] && expires_in > 0 && !options[:raw]
84
- expires_in += 5.minutes
85
- end
86
- if options[:unless_exist]
87
- @cache.set_unless_exists(key, payload, expires_in)
88
- else
89
- @cache.set(key, payload, expires_in)
90
- end
91
- end
92
-
93
- # Delete an entry from the cache.
94
- def delete_entry(key, **options)
95
- return @cache.delete(key)
96
- end
97
-
98
- end
99
- end
100
- end