test/test_zache.rb in zache-0.12.0 vs test/test_zache.rb in zache-0.13.0
- old
+ new
@@ -1,10 +1,10 @@
# frozen_string_literal: true
# (The MIT License)
#
-# Copyright (c) 2018 Yegor Bugayenko
+# Copyright (c) 2018-2023 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -30,11 +30,11 @@
Thread.report_on_exception = true
# Cache test.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
-# Copyright:: Copyright (c) 2018 Yegor Bugayenko
+# Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
# License:: MIT
class ZacheTest < Minitest::Test
def test_caches
cache = Zache.new(sync: false)
first = cache.get(:hey, lifetime: 5) { Random.rand }
@@ -70,9 +70,16 @@
cache.get(:hey) { Random.rand }
exists_result = cache.exists?(:hey)
not_exists_result = cache.exists?(:bye)
assert(exists_result == true)
assert(not_exists_result == false)
+ end
+
+ def test_put_and_exists
+ cache = Zache.new
+ cache.put(:hey, 'hello', lifetime: 0.1)
+ sleep 0.2
+ assert(!cache.exists?(:hey))
end
def test_remove_key
cache = Zache.new
cache.get(:hey) { Random.rand }