From 76c8b7f1c8fbc91fd612e558743e65116fdfd3e5 Mon Sep 17 00:00:00 2001 From: _ <53088156+636f7374@users.noreply.github.com> Date: Tue, 14 Apr 2020 09:22:34 +0800 Subject: [PATCH] Rename Cache Item -> Entry. --- src/durian/cache.cr | 24 ++++++++++++------------ src/durian/cache/ip_address.cr | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/durian/cache.cr b/src/durian/cache.cr index 5fc7f3e..41e09c1 100644 --- a/src/durian/cache.cr +++ b/src/durian/cache.cr @@ -150,16 +150,16 @@ class Durian::Cache class RecordKind property accessAt : Time property tapCount : Int32 - property a : Item? - property aaaa : Item? - property ns : Item? - property ptr : Item? - property cname : Item? - property soa : Item? - property txt : Item? - property mx : Item? - property dname : Item? - property srv : Item? + property a : Entry? + property aaaa : Entry? + property ns : Entry? + property ptr : Entry? + property cname : Entry? + property soa : Entry? + property txt : Entry? + property mx : Entry? + property dname : Entry? + property srv : Entry? def initialize(@accessAt : Time = Time.local, @tapCount : Int32 = 0_i32) @a = nil @@ -184,7 +184,7 @@ class Durian::Cache {% for name in RecordType %} def create_{{name.downcase.id}} - @{{name.downcase.id}} = Item.new + @{{name.downcase.id}} = Entry.new end {% end %} @@ -222,7 +222,7 @@ class Durian::Cache record? flag end - class Item + class Entry property packet : Durian::Packet::Response? property updateAt : Time diff --git a/src/durian/cache/ip_address.cr b/src/durian/cache/ip_address.cr index 5d7a76b..b103f1f 100644 --- a/src/durian/cache/ip_address.cr +++ b/src/durian/cache/ip_address.cr @@ -1,20 +1,20 @@ module Durian class Cache::IPAddress - property collects : Immutable::Map(String, Item) + property collects : Immutable::Map(String, Entry) property capacity : Int32 property cleanInterval : Time::Span property recordExpires : Time::Span property cleanAt : Time property maximumCleanup : Int32 - def initialize(@collects = Immutable::Map(String, Item).new, @capacity : Int32 = 256_i32, + def initialize(@collects = Immutable::Map(String, Entry).new, @capacity : Int32 = 256_i32, @cleanInterval : Time::Span = 3600_i32.seconds, @recordExpires : Time::Span = 1800_i32.seconds) @cleanAt = Time.local @maximumCleanup = (capacity / 2_i32).to_i32 end def insert(name : String, ip_address : Array(Socket::IPAddress)) - insert = collects.set name, Item.new ip_address + insert = collects.set name, Entry.new ip_address @collects = insert end @@ -159,7 +159,7 @@ module Durian end {% end %} - class Item + class Entry property ipAddress : Array(Socket::IPAddress) property accessAt : Time property tapCount : Int32