GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ’– GOLF(2gg) πŸ’–

okay bestie, welcome to the Golf manual, gg edition πŸŽ€ this one's all about new-hash, and no cap, it's a little cutie.


✨ NAME ✨

new-hash β€” the hash-maker (it's giving "hash" energy, fr fr) πŸ¦‹


🎯 PURPOSE 🎯

Create hash. That's it. That's the whole vibe. Slay. πŸ’…


πŸ“œ SYNTAX πŸ“œ

new-hash <hash> \
    [ process-scope ] \
    [ hash-size <hash size> ]

like… look at her. gorgeous. ✨


🌸 DESCRIPTION 🌸

so new-hash creates a new <hash>. and what even is a hash, you ask? bestie. a hash is a collection of key/value pairs β€” those are called "elements" β€” and you get a value of an element based on its key value. that's the whole deal. iykyk πŸ”‘

πŸ”’ SCOPE πŸ”’

okay this part matters, so listen up πŸ‘‘

a hash is accessible to the current request only… unless you use the process-scope clause, in which case all requests served by a process can use it. (peep do-once for a typical way to create a hash with a process scope, bestie 🫢)

if you do use process-scope, then <hash> will keep its data across all requests in a given process. and yes, write-hash has an example of a process-scoped hash if you wanna see it in the wild. 🌈

πŸ“ SIZING A HASH πŸ“

a hash can be any size, as long as there's enough memory for it. simple as that.

the hash-size refers to the size of a hash table used to provide high-performance access to its elements based on a key. basically: how big is the shelf we're putting stuff on πŸ—„οΈ

<hash size> is the number of "buckets" used by the hash (it is 10 by default, lowkey tiny but it's the default, periodt). all hash elements with the same hash code get stored in a linked list within the same bucket. so a greater <hash size> generally means less elements per bucket and better performance πŸ”₯

however β€” and this is the part where we stay humble β€” memory usage grows with a bigger hash table. so <hash size> should be balanced based on the program needs. it's giving "treat her right, don't go feral" energy πŸ’…

Golf uses the high-performing FNV1_a hash algorithm, iconic behavior tbh. each element in a bucket list is lightweight β€” it contains pointers to a key, a value, and the next element in the linked list. so smol. so efficient. we love her πŸŽ€

⚠️ <hash size> must be at least 256. if less, it will be set to 256. no negotiating, bestie, the algorithm said what it said πŸ’€

πŸ’« EXAMPLES πŸ’«

create a new hash with 5000 buckets:

new-hash h hash-size 5000

and if you want more examples, go check out read-hash β€” she's got the receipts πŸ“š


πŸ‘€ SEE ALSO πŸ‘€

  • Hash
  • get-hash
  • new-hash
  • purge-hash
  • read-hash
  • resize-hash
  • write-hash
  • See all documentation

and that's the whole page, bestie 🫢 go forth and hash responsibly. this was the GOLF(2gg) page, version $VERSION, dated $DATE β€” mwah, take care of her πŸ’–βœ¨

πŸ“¦ where this page comes from