<commit_before>#!/usr/bin/php
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__).'/lib');

$configFile = dirname(__FILE__).'/config.php';

$config = array();
require_once($configFile);

$connectionClass = $config['classes']['connection'];
$clientClass = $config['classes']['client'];
$connectionFile = str_replace('\\', DIRECTORY_SEPARATOR, trim($connectionClass, '\\')).'.php';
$clientFile = str_replace('\\', DIRECTORY_SEPARATOR, trim($clientClass, '\\')).'.php';

require_once('CacheQueue/IConnection.php');
require_once('CacheQueue/IClient.php');
require_once($connectionFile);
require_once($clientFile);

$connection = new $connectionClass($config['connection']);
$client = new $clientClass($connection);

$result = $client->getOrQueue('example_data', 'store', 'random '.  rand(100, 999), time() + 10);
echo 'Client: result '.($result === false ? 'false' : $result).'.'."\n";<commit_msg>improved example client file<commit_after>#!/usr/bin/php
<?php

function getCacheQueueClient() {
    static $client = null;
    
    if ($client) {
        return $client;
    }
    
    
    //define config file
    $configFile = dirname(__FILE__).'/config.php';

    
    $config = array();
    require_once($configFile);

    $connectionClass = $config['classes']['connection'];
    $clientClass = $config['classes']['client'];
    
    //load required classes - uncomment if you don't use an autoloader 
    /*
    $connectionFile = str_replace('\\', DIRECTORY_SEPARATOR, trim($connectionClass, '\\')).'.php';
    $clientFile = str_replace('\\', DIRECTORY_SEPARATOR, trim($clientClass, '\\')).'.php';

    //add CacheQueue parent folder to include path
    set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__).'/lib');
    require_once('CacheQueue/IConnection.php');
    require_once('CacheQueue/IClient.php');
    require_once($connectionFile);
    require_once($clientFile);
    */
    

    $connection = new $connectionClass($config['connection']);
    $client = new $clientClass($connection);
    
    return $client;
}


$client = getCacheQueueClient();
$result = $client->getOrQueue('example_data', 'store', 'random '.  rand(100, 999), time() + 10);
echo 'Client: result '.($result === false ? 'false' : $result).'.'."\n";
{'fraction_non_alphanumeric': 0.19049714034315882, 'fraction_numerical': 0.007039155301363837, 'mean_word_length': 4.685, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5652688', 'n_tokens_mistral': 732, 'n_tokens_neox': 703, 'n_words': 133}