As chaves e valores em um banco de dados de Berkeley em Ruby Be Strings, não int, flutuando ou qualquer outro tipo?
-
05-07-2019 - |
Pergunta
Parece que, se eu usar Berkeley DB (DBM) no Ruby, as chaves e os valores do hash devem ser strings? Eles podem ser outro tipo de dados?
require 'dbm'
d = DBM.open('test1')
d[1] = 2
d[123] = 456
d[2] = 2.34
d['wa'] = Time.now.to_f
p d.keys
p d.values
Resultado:
C:\>ruby test_dbm.rb
["wa", "2", "1", "123"]
["1259229787.686", "2.34", "2", "456"]
Solução
Yes, they do store key values as arbitrary byte strings that can be fixed-length or variable-length. I also realised that recently when I had to use bdb in one of our projects.
And you can see the key values on command line by typing
strings full/bdb/file/path
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow