Module resty.dns.balancer.handle
Handle module.
 Implements handles to be used by the objBalancer:getPeer method. These
 implement a __gc method for tracking statistics and not leaking resources
 in case a connection gets aborted prematurely.
This module is only relevant when implementing your own balancer algorithms.
Info:
- Copyright: 2016-2020 Kong Inc. All rights reserved.
- License: Apache 2.0
- Author: Thijs Schreijer
Functions
| get (__gc) | Gets a handle from the cache. | 
| release (handle) | Returns a handle to the cache. | 
| setCacheSize (size) | Sets a new cache size. | 
Functions
- get (__gc)
- 
    Gets a handle from the cache.
 The handle comes from the cache or it is newly created. A handle is just a
 table. It will have two special fields:
- __udata: (read-only) a userdata used to track the lifetime of the handle
- __gc: (read/write) this method will be called on GC.
 NOTE: the __gcwill only be called when the handle is garbage collected, not when it is returned by calling release.Parameters:- __gc (optional, function) the method called when the handle is GC'ed.
 Returns:- 
        handle
    
 Usage:local handle = _M local my_gc_handler = function(self) print(self.name .. " was deleted") end local h1 = handle.get(my_gc_handler) h1.name = "Obama" local h2 = handle.get(my_gc_handler) h2.name = "Trump" handle.release(h1) -- explicitly release it h1 = nil h2 = nil -- not released, will be GC'ed collectgarbage() collectgarbage() --> "Trump was deleted" 
- release (handle)
- 
    Returns a handle to the cache.
 The handle will be cleared, returned to the cache, and its __gchandle will NOT be called.Parameters:- handle the handle to return to the cache
 Returns:- 
        nothing
    
 
- setCacheSize (size)
- 
    Sets a new cache size.  The default size is 1000.
    Parameters:- size the new size.
 Returns:- 
        nothing, or throws an error on bad input