Sha256: 2a27ad4e569fe93986008481c76d0b16ad80c34fd95dbe24210a6f0ce2f7ef14
Contents?: true
Size: 1.21 KB
Versions: 7
Compression:
Stored size: 1.21 KB
Contents
require "socrates/core/state_data" module Socrates module Storage module Storage def initialize @logger = Socrates.config.logger end def fetch(client_id) key = generate_key(client_id) snapshot = get(key) return if snapshot.nil? begin Socrates::Core::StateData.deserialize(snapshot) rescue StandardError => e @logger.warn "Error while fetching state_data for client id '#{client_id}', resetting state: #{e.message}" @logger.warn e end end def persist(client_id, state_data) key = generate_key(client_id) state_data.reset_elapsed_time put(key, state_data.serialize) end def generate_key(client_id) client_id end # rubocop:disable Lint/UnusedMethodArgument def has_key?(key) raise NotImplementedError end def clear(key) raise NotImplementedError end def get(key) raise NotImplementedError end def put(key, value) raise NotImplementedError end def clear_all raise NotImplementedError end # rubocop:enable Lint/UnusedMethodArgument end end end
Version data entries
7 entries across 7 versions & 1 rubygems