Sha256: 65a839ea91aa6bb183bd3d56a3d0ac1cbb4403d7e28affc559417dbdea675d7b
Contents?: true
Size: 963 Bytes
Versions: 3
Compression:
Stored size: 963 Bytes
Contents
require 'sequel' require 'base64' module VinExploder module Cache # A VinExploder cache adapter using Sequel for saving the decoded vin attributes. # # this store assumes there are 2 columns on the table: # - *key*: the first 8, 10th and 11th characters of the vin # - *data*: A hash of the decoded vin attributes class SequelCacheStore < Store def initialize(options = {}) super @connection = Sequel.connect(options) end def read(vin) key = make_vin_cache_key(vin) data = @connection[:vins].where(:key => key).first Marshal.load(data[:data]) unless data.nil? end def write(vin, hash) key = make_vin_cache_key(vin) @connection[:vins].insert(:key => key, :data => Marshal.dump(hash)) hash end def delete(vin) key = make_vin_cache_key(vin) result = @connection[:vins].where(:key => key).delete result > 0 end end end end
Version data entries
3 entries across 3 versions & 1 rubygems