- dbDictType used as argument to dictCreate in server.c (initServer)
- Uses dictSdsHash, dictSdsKeyCompare, dictSdsKeyDestructor, dictObjectDestructor
- dict struct:
- dictType
- privdata
- ht (2 of them)
- rehashidx
- iterators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):138:0> [256].pack('S') > [15].pack('S') | |
=> false | |
irb(main):139:0> [256].pack('S>') > [15].pack('S>') | |
=> true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'securerandom' | |
require_relative './dict' | |
RANDOM_BYTES = SecureRandom.bytes(16) | |
class MyHash | |
def initialize(pairs) | |
if pairs.length == 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'securerandom' | |
require_relative './dict' | |
RANDOM_BYTES = SecureRandom.bytes(16) | |
def setup_dict(size) | |
dict = BYORedis::Dict.new | |
size.times { |i| dict[i.to_s] = i.to_s } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
socket = TCPSocket.new 'localhost', 2000 | |
socket.write "request" | |
socket.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
# EPIPE, when the socket is closed by the time we try to read, we can read, but writing fails | |
# ECONNRESET, when the socket is closed by the time we try to write | |
def process_events(event) | |
p 'in proccess' | |
res = event.read_nonblock(1024, exception: false) # => YET THE FUCKING STACKTRACE POINTS HERE WHEN ECONNRESET | |
p res | |
event.puts "FUCK YOU puts" # => EPIPE | |
# p '==--==' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fiddle' | |
class BYOArray < BasicObject | |
PTR_SIZE = ::Fiddle::SIZEOF_LONG | |
def initialize(max_size) | |
@max_size = max_size | |
@current_size = 0 | |
@beginning_address = ::Fiddle::Pointer.malloc(PTR_SIZE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Railway { | |
sealed trait TwoTrack[F] | |
case class Success[S](data: S) extends TwoTrack[S] | |
case class Failure[S](message: String) extends TwoTrack[S] | |
def succeed[S](x: S) = Success(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Railway { | |
sealed trait TwoTrack[F] | |
case class Success[S](data: S) extends TwoTrack[S] | |
case class Failure[S](message: String) extends TwoTrack[S] | |
def succeed[S](x: S) = Success(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final case class OrderRequest(cardNumber: String) | |
// ... | |
val route = | |
path("order") { | |
post { | |
entity(as[OrderRequest]) { orderRequest => | |
onComplete(PurchaseService.createPurchase(orderRequest.cardNumber)) { | |
case Success(Right(result)) => | |
complete(StatusCodes.Created, result) | |
case Success(Left(error)) => |