persistent_hash 0.0.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 06b320eea13bba423859587cff01a544d305ec19
4
- data.tar.gz: 2c5a643b36f877b1aaa3ad210fee8c011a73f750
2
+ SHA256:
3
+ metadata.gz: fb9b3d2c05cc4d5885e17e6c4eac35f089805e743849b94059af62b73f9a6416
4
+ data.tar.gz: d2ee8a193905678f80465844a6f2dc09388d11d1b29bcfeecc5f52e4fb0bc6e2
5
5
  SHA512:
6
- metadata.gz: 71cfed0122f4b6599e573004a3aa69fb167af398f75ce5f710dbe6ad96d2cd54f33f348de365397d533dc2da2183ddced1fa11665fb38743310bdbdf98d0f123
7
- data.tar.gz: ad6f5667e8316b8d24ad130e8d5ba0010f927dce8b9c707fd98511fded7c5f3d9acf3443f70625ee110c0febfb4b247e797fd253a81880a963d5161210ae6cae
6
+ metadata.gz: 6abc3c1cfacb0d9ce6ca40b1b05a5d2a8d4c454ac5a8160021308ee9f35ac0ce2965d148fd499fd68d8e3d7710e48636b7a2c8b593779a6d1dbaad62e259d474
7
+ data.tar.gz: 9dd856613e1e757657aa41bfbcc3d21ebd503b25b1da3ebb7fcbe913ec1f24e9da6f0bf8c8b95a7d199ef11b4abc988e92c2a4ea4687c513abd830eb013afa5c
@@ -1,22 +1,21 @@
1
1
  module PersistentHash
2
2
  class Hash < ActiveRecord::Base
3
-
4
3
  self.table_name = 'persistent_hash'
5
4
 
6
5
  # save a value in the hash
7
6
  def self.[]=(key_name, value)
8
- transaction do
9
- where(key_name: key_name).delete_all
10
-
11
- if ! value.nil?
12
- formatted = PersistentHash::Formatter.format(value)
7
+ item = where(key_name: key_name)
8
+ .lock
9
+ .first_or_initialize
13
10
 
14
- create!(
15
- key_name: key_name,
16
- readable_value: formatted,
17
- marshalled: Base64.encode64(Marshal.dump(value))
18
- )
19
- end
11
+ if value.nil?
12
+ item.destroy
13
+ else
14
+ formatted = PersistentHash::Formatter.format(value)
15
+ item.update(
16
+ readable_value: formatted,
17
+ marshalled: Base64.encode64(Marshal.dump(value))
18
+ )
20
19
  end
21
20
  end
22
21
 
@@ -32,6 +31,5 @@ module PersistentHash
32
31
 
33
32
  value
34
33
  end
35
-
36
34
  end
37
35
  end
@@ -1,4 +1,4 @@
1
- class CreatePersistentHash < ActiveRecord::Migration
1
+ class CreatePersistentHash < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :persistent_hash do |t|
4
4
  t.string :key_name, null: false
@@ -7,6 +7,6 @@ class CreatePersistentHash < ActiveRecord::Migration
7
7
  t.datetime :updated_at, null: false
8
8
  end
9
9
 
10
- add_index :persistent_hash, :key_name, unique: true
10
+ add_index :persistent_hash, :key_name, unique: true, name: 'persistent_hash_uniq'
11
11
  end
12
12
  end
@@ -1,4 +1,4 @@
1
- class ConvertReadableValueToText < ActiveRecord::Migration
1
+ class ConvertReadableValueToText < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  change_column :persistent_hash, :readable_value, :text
4
4
  end
@@ -0,0 +1,5 @@
1
+ class Utf8Mb4 < ActiveRecord::Migration[5.2]
2
+ def change
3
+ change_column 'persistent_hash', 'key_name', :string, limit: 191
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module PersistentHash
2
- VERSION = "0.0.6"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persistent_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-02 00:00:00.000000000 Z
11
+ date: 2019-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,16 +16,30 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.1'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: sqlite3
28
+ name: mysql2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pg
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -97,7 +111,7 @@ dependencies:
97
111
  description: Handy place to stick small bits of persistent data. Like redis if you
98
112
  don't want to install redis.
99
113
  email:
100
- - alex@crackpot.org
114
+ - github@mostlyalex.com
101
115
  executables: []
102
116
  extensions: []
103
117
  extra_rdoc_files: []
@@ -108,6 +122,7 @@ files:
108
122
  - app/models/persistent_hash/hash.rb
109
123
  - db/migrate/20150518213536_create_persistent_hash.rb
110
124
  - db/migrate/20161110111600_convert_readable_value_to_text.rb
125
+ - db/migrate/20190618182005_utf8_mb4.rb
111
126
  - lib/persistent_hash.rb
112
127
  - lib/persistent_hash/engine.rb
113
128
  - lib/persistent_hash/version.rb
@@ -132,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
147
  version: '0'
133
148
  requirements: []
134
149
  rubyforge_project:
135
- rubygems_version: 2.4.8
150
+ rubygems_version: 2.7.6.2
136
151
  signing_key:
137
152
  specification_version: 4
138
153
  summary: ActiveRecord-based key/value store for Rails applications.