Module: Tiny::Redis::ClassMethods
- Defined in:
- lib/tiny/redis.rb
Instance Method Summary collapse
Instance Method Details
#load(index) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/tiny/redis.rb', line 21 def load(index) key, crypt = setup(index) $redis.with do |r| encrypted = r.get(key) return nil if encrypted.nil? JSON.parse(crypt.decrypt_and_verify(encrypted), object_class: self) end end |
#setup(index) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/tiny/redis.rb', line 31 def setup(index) key = Digest::SHA1.hexdigest(index) encrypt_key = Rails.application.credentials.user[:encryptkey] crypt = ActiveSupport::MessageEncryptor.new(encrypt_key) return [key, crypt] end |