This file contains 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
#!/usr/bin/env perl | |
use v5.12; | |
use warnings; | |
use strict; | |
use Cache::Memcached; | |
my $memd = Cache::Memcached->new(); | |
$memd->set_servers(["localhost:11212"]); | |
open(my $fh,"<","/usr/share/dict/words") || die "open $!"; | |
my $line = <$fh>; # get rid of first empty line |
This file contains 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
#lang racket | |
(require (planet "memcached.rkt" ("jaymccarthy" "memcached.plt" 1 0))) | |
(define loaddict | |
(lambda (fn) | |
(letrec (;; our input handle | |
[in (open-input-file fn)] | |
;; our memcache conn | |
[mc (memcached "localhost" 11212)] | |
;; our function for walking the file |
This file contains 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
module Main where | |
import qualified Data.List as L | |
import qualified Control.Monad as C | |
import qualified Network.Memcache as MC | |
import qualified Network.Memcache.Protocol as S | |
setword conn word = do | |
success <- MC.set conn word (1 :: Int) | |
C.when (success == False) $ print word | |
return success |
This file contains 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
module Main where | |
import qualified Data.List as L | |
import qualified Control.Monad as C | |
import qualified Network.Memcache as MC | |
import qualified Network.Memcache.Protocol as S | |
import qualified Data.ByteString.Char8 as BC | |
setword conn word = do | |
let b_word = BC.unpack word | |
success <- MC.set conn b_word (1 :: Int) |
This file contains 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
module Main where | |
import qualified Control.Monad as C | |
import qualified Network.Memcache as MC | |
import qualified Network.Memcache.Protocol as S | |
main = do | |
conn <- S.connect "127.0.0.1" 11212 | |
words <- (C.liftM lines . readFile) "/etc/dictionaries-common/words" | |
sets <- C.mapM_ (\w -> MC.set conn w (1::Int)) words | |
S.disconnect conn |
This file contains 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
#lang racket | |
(require racket/file) | |
(require (planet "memcached.rkt" ("jaymccarthy" "memcached.plt" 1 0))) | |
(define loaddict | |
(lambda (fn) | |
(let ([mc (memcached "localhost" 11212)] | |
[lines (file->bytes-lines fn)]) | |
(for-each (lambda (l) | |
(if (> (bytes-length l) 0) |
This file contains 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
package main | |
import ( | |
"fmt" | |
"os" | |
"bufio" | |
memcache "github.com/bradfitz/gomemcache" | |
) | |
func main() { |
This file contains 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
#lang racket | |
(require racket/file) | |
(require (planet "memcached.rkt" ("jaymccarthy" "memcached.plt" 1 0))) | |
(define loaddict | |
(lambda (fn) | |
(let ([mc (memcached "localhost" 11212)]) | |
(for-each (lambda (l) | |
(if (> (bytes-length l) 0) | |
(memcached-set! mc l #"1") |
This file contains 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
{-# LANGUAGE ScopedTypeVariables #-} | |
module Main where | |
import qualified Control.Monad as C | |
import qualified Data.Char as CH | |
import qualified Data.Maybe as M | |
import qualified Data.List as L | |
import qualified Network.Memcache as MC | |
import qualified Network.Memcache.Protocol as MCP | |
import qualified Network.Memcache.Key as MCK |
This file contains 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
module Main where | |
import Control.Monad | |
import Control.Monad.STM | |
import Control.Concurrent | |
import Control.Concurrent.STM | |
oneSecond = 1000000 | |
writerThread :: TChan Int -> IO () |