首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ETS创建返回值

ETS创建返回值
EN

Stack Overflow用户
提问于 2018-04-03 15:00:48
回答 1查看 164关注 0票数 3

我用的是药剂1.6.3。我正在使用Elixir中的Erlang :ets模块,我对:ets.new/2函数的返回值感到有点困惑。

根据医生的例子,当调用:ets.new(:whatever, [])时,应该返回似乎是整数的值:

代码语言:javascript
复制
iex> table = :ets.new(:buckets_registry, [:set, :protected])
8207

然而,当我在iex中运行完全相同的代码时,我得到了一个引用:

代码语言:javascript
复制
iex(1)> table = :ets.new(:buckets_registry, [:set, :protected])     
#Reference<0.1885502827.460455937.234656>

那么,自文档编写以来,有什么变化吗?还是完全一样,我对什么是引用感到困惑?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-03 15:04:03

是的,ets:new的返回值从一个整数更改为Erlang/OTP20.0中的引用。来自自述

代码语言:javascript
复制
  OTP-14094    Application(s): stdlib

               *** POTENTIAL INCOMPATIBILITY ***

               Optimized ETS operations by changing table identifier
               type from integer to reference. The reference enables a
               more direct mapping to the table with less potential
               lock contention and makes especially creation and
               deletion of tables scale much better.

               The change of the opaque type for the ETS table
               identifiers may cause failure in code that make faulty
               assumptions about this opaque type.

               The number of tables stored at one Erlang node *used*
               to be limited. This is no longer the case (except by
               memory usage). The previous default limit was about
               1400 tables and could be increased by setting the
               environment variable ERL_MAX_ETS_TABLES before starting
               the Erlang runtime system. This hard limit has been
               removed, but it is currently useful to set the
               ERL_MAX_ETS_TABLES anyway. It should be set to an
               approximate of the maximum amount of tables used. This
               since an internal table for named tables is sized using
               this value. If large amounts of named tables are used
               and ERL_MAX_ETS_TABLES hasn't been increased, the
               performance of named table lookup will degrade.
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49633255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档