From efd81f4f6be4e91225aa893787d4ede84b46ed5e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 26 Dec 2016 23:04:57 +0000 Subject: introduce mcache class for caching audio metadata We often waste cycles rerunning commands we don't need to run frequently. Introduce a short term cache for these. --- test/test_mcache.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/test_mcache.rb (limited to 'test') diff --git a/test/test_mcache.rb b/test/test_mcache.rb new file mode 100644 index 0000000..6957021 --- /dev/null +++ b/test/test_mcache.rb @@ -0,0 +1,19 @@ +# Copyright (C) 2016 all contributors +# License: GPL-3.0+ +# frozen_string_literal: true +require './test/helper' +require 'dtas/mcache' + +class TestMcache < Testcase + def test_mcache + mc = DTAS::Mcache.new + exist = nil + mc.lookup('hello') { |infile, hash| exist = hash } + assert_kind_of Hash, exist + assert_equal 'hello', exist[:infile] + assert_operator exist[:btime], :<=, DTAS.now + assert_same exist, mc.lookup('hello') + assert_nil mc.lookup('HELLO') + assert_same exist, mc.lookup('hello'), 'no change after miss' + end +end -- cgit v1.2.3-24-ge0c7