This commit is contained in:
2019-02-06 00:49:12 +03:00
commit 8dbb1bb605
4796 changed files with 506072 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
Version 0.9.1 - 12 Oct 2003
-- Altered the SockIO helper class, so it no longer allows accessing
the streams it contains directly, instead it has methods
with identical signatures to the methods that were called
on the streams... This makes the client code prettier.
-- Changed looped non blocking read to blocking read, for getting
items from the server. This probably reduces CPU usage in
cases where the retrieval would block, and cleans up the
code a bit. We're blocking on retrieval anyhow.
-- Made get() not call get_multi(), and added single socket
optimization. This parallels recent changes to the perl
client
-- Changed a few for loops to use iterators instead, since it's
probably marginally more efficient, and it's probably
better coding practice.
-- Actually spell checked. :)
Version 0.9.0 - 29 Sep 2003
-- Renumbered to reflect that it's not been realworld tested
-- changed package to danga.com.MemCached (thanks)
-- added dates to changelog
-- added .txt to text files
-- added to official memcached site :)
Version 1.0.0 - 28 Sep 2003
-- Adjusted namespacing for SockIO, it shouldn't have been public; is now package level.
As a bonus, this means I don't have to Javadoc it. :)
-- Finished adding complete Javadoc to MemCachedClient.
-- spellchecked
-- added a couple versions of function variations that I missed. for example, some that
didn't take an int directly as a hash value, and i missed a get_multi w/out hashes.
-- removed java.net.Socket reference from MemCachedClient, SockIO has a new constructor which
takes hostname and port number
-- switched to three part version number
Version 0.3 - 27 Sep 2003
-- Compression, for strings/stringified numbers, this is compatible w/ perl
Serialized objects are incompatible w/ perl for obvious reasons. :)
-- Added PORTABILITY file, to include information about using the client
with various JVM's
-- Updated string parsing to StreamTokenizer rather than regexp's in an
effort to get sablevm to like the client
Version 0.2 - 24 Sep 2003
-- Serialization works
-- Possible BUG: Only the lower byte of the characters of keys are sent
This is only a problem if the memcache server can handle
unicode keys. (I haven't checked)
-- Server Failures handled gracefully
-- Partial Javadoc
Version 0.1 - 23 Sep 2003
-- Initial Release
-- Storing and Retrieving numbers and strings works

View File

@@ -0,0 +1,18 @@
This file lists the portability status of this client. Please send me any
additional information.
Richard 'toast' Russo <russor@msoe.edu>
I have personally tested this on the following platforms, and it works to the
best of my knowledge:
Sun's JRE 1.4.2 on Linux/i86
kaffe 1.1.1 on Linux/i86
I have personally tested this on the following platforms, and it does not work:
sablevm 1.0.9: complains of todo in native_interface.c
gjc(jdk) 3.3.2 20030908 (Debian prerelease): strange compiler errors
gij(jre) 3.3.2 20030908 (Debian prerelease): does not get items from server properly

View File

@@ -0,0 +1,9 @@
This are the things left to do
Investigate threading issues (what needs to be synchronized)
Investigate 3rd party jvm incompatibility
Non deprecated stream input
Extensive testing

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,72 @@
/**
* MemCached Java client, utility class for Socket IO
* Copyright (c) 2003
* Richard 'toast' Russo <russor@msoe.edu>
* http://people.msoe.edu/~russor/memcached
*
*
* This module is Copyright (c) 2003 Richard Russo.
* All rights reserved.
* You may distribute under the terms of the GNU General Public License
* This is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.
*
* @author Richard 'toast' Russo <russor@msoe.edu>
* @version 0.9.1
*/
package com.danga.MemCached;
import java.util.*;
import java.net.*;
import java.io.*;
class SockIO {
Socket sock;
DataInputStream in;
DataOutputStream out;
boolean closed = false;
public SockIO(String host, int port) throws IOException {
sock = new Socket(host,port);
in = new DataInputStream(sock.getInputStream());
out = new DataOutputStream(sock.getOutputStream());
}
public void close() {
closed = true;
try {
in.close();
out.close();
sock.close();
} catch (IOException e) {
}
}
public boolean isConnected() {
return (closed && sock.isConnected());
}
public void readFully(byte[] b) throws IOException {
in.readFully(b);
}
public String readLine() throws IOException {
return in.readLine();
}
public void writeBytes(String s) throws IOException {
out.writeBytes(s);
}
public void flush() throws IOException {
out.flush();
}
public void write(byte[] b) throws IOException {
out.write(b);
}
}

View File

@@ -0,0 +1,79 @@
#!/usr/bin/perl
#
# Simplify Brad's life. I'm sure there's a Java-specific way
# to do this (or there should be), but I don't have Java
# installed.
#
use strict;
use Getopt::Long;
my $opt_tar = 0;
my $opt_upload = 0;
exit 1 unless GetOptions("tar" => \$opt_tar,
"upload" => \$opt_upload);
# chdir to the directory the script's at, so future
# paths need only be relative
use FindBin qw($Bin);
chdir $Bin or die "Couldn't cd to $Bin\n";
die "Must use --tar or --upload\n" unless $opt_tar || $opt_upload;
# files to distribute
my @manifest = qw(
TODO.txt
PORTABILITY.txt
CHANGELOG.txt
memcachetest.java
com
com/danga
com/danga/MemCached
com/danga/MemCached/MemCachedClient.java
com/danga/MemCached/SockIO.java
);
# figure out the version number
open (F, "com/danga/MemCached/MemCachedClient.java") or die;
{ local $/ = undef; $_ = <F>; } # suck in the whole file
close F;
die "Can't find version number\n" unless
/\@version\s+(\d[^\'\"\s]+)/s;
my $ver = $1;
my $dir = "java-memcached-$ver";
my $dist = "$dir.tar.gz";
if ($opt_tar) {
# make a fresh directory
mkdir $dir or die "Couldn't make directory: $dir\n";
# copy files to fresh directory
foreach my $file (@manifest) {
if (-f $file) {
system("cp", $file, "$dir/$file")
and die "Error copying file $file\n";
} elsif (-d $file) {
mkdir "$dir/$file"
or die "Error creating directory $file\n";
}
}
# tar it up
system("tar", "zcf", $dist, $dir)
and die "Error running tar.\n";
# remove temp directory
system("rm", "-rf", $dir)
and die "Error cleaning up temp directory\n";
print "$dist created.\n";
}
if ($opt_upload) {
print "Uploading $dist...\n";
system("scp", $dist, 'bradfitz@danga.com:memd/dist/')
and die "Error uploading to memcached/dist\n";
}
print "Done.\n";

View File

@@ -0,0 +1,61 @@
/*
* memcachetest.java
*
* Created on September 23, 2003, 12:23 AM
*/
/**
*
* @author toast
*/
import com.danga.MemCached.*;
import java.util.ArrayList;
/** This is an example program using a MemCacheClient. */
public class memcachetest {
/** Creates a new instance of memcachetest */
public memcachetest() {
}
/** This runs through some simple tests of the MemCacheClient.
* @param args the command line arguments
*/
public static void main(String[] args) {
MemCachedClient mcc = new MemCachedClient();
String[] serverlist = { "localhost:12345"}; //, "localhost:12346"};
mcc.set_compress_enable(true);
mcc.set_compress_savings(0.0); // compress everthing
mcc.set_compress_threshold(0); // compress everthing
mcc.set_servers(serverlist);
//mcc.set_serial(true);
// Integer foo = new Integer(-2);
mcc.set("foo", "Your mother eats army boots, in the day time, with her friends. " +
"English text should be nice and compressible.");
Object tmp = mcc.get("foo");
System.out.println(tmp);
System.out.println("Sleeping ...");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
while (mcc.get("foo") == null) {
System.out.print(".");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
}
System.out.println(mcc.get("foo"));
}
}