Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

PHP Extension Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(PHP Extension) Large Persistent Hash Table Stored on Filesystem

Demonstrates how to implement a large, persistent hash table that is stored on the filesystem and allows for quick retrieval using a hash key.

Chilkat PHP Downloads

PHP Extension for Windows, Linux, MacOS,
Alpine Linux, Solaris

<?php

include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0

// Let's say we would like to implement a persistent hash table with approximately 200,000 entries.
// We want something simple and straightforward.
// 
// The Chilkat Cache class is a solution that might fit.
// 
// Each hash table entry is a file.  Depending on the number of anticipated hash entries,
// the files can be contained in a single directory, or a collection of 256 directories,
// or a collection of 256x256 directories.

// There are 3 options:
// 
// Level 0: All cache files are in a single directory (the cache root).
// Level 1: Cache files are located in 256 sub-directories numbered 0 .. 255 directly under the cache root.
// Level 2: There are two levels of sub-directories under the cache root. 
//          The 1st level has 256 sub-directories numbered 0 .. 255 directly under the cache root. 
//          The 2nd level allows for up to 256 sub-directories (0..255) under each level-1 directory. 
//          Cache files are stored in the leaf directories. 

// For this example, given that we anticipate a larger number of hash entries, we choose a "level 2" cache.
$cache = new CkCache();

// We can also spread the cache among several root directories, but for this example we'll only use one root directory.
// Call AddRoot once for each root directory.
$cache->AddRoot('c:/temp/myCache');
$cache->put_Level(2);

// Add some key/values to the persisted hash table (i.e. the cache).
// The eTag is optional metadata.
$key = 'apple';
$eTag = '';
$itemValue = 'macos';
$success = $cache->SaveTextNoExpire($key,$eTag,$itemValue);

// Add more items..
$success = $cache->SaveTextNoExpire('microsoft','','windows');
$success = $cache->SaveTextNoExpire('google','','android');

// Lookup items:
$key = 'microsoft';
$itemValue = $cache->fetchText($key);
print $key . ': ' . $itemValue . "\n";

$key = 'apple';
$itemValue = $cache->fetchText($key);
print $key . ': ' . $itemValue . "\n";

?>

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.