00001 /******************************************************************************* 00002 00003 @file IBitBucket.d 00004 00005 Copyright (C) 2004 Kris Bell 00006 00007 00008 This software is provided 'as-is', without any express or implied 00009 warranty. In no event will the authors be held liable for damages 00010 of any kind arising from the use of this software. 00011 00012 Permission is hereby granted to anyone to use this software for any 00013 purpose, including commercial applications, and to alter it and/or 00014 redistribute it freely, subject to the following restrictions: 00015 00016 1. The origin of this software must not be misrepresented; you must 00017 not claim that you wrote the original software. If you use this 00018 software in a product, an acknowledgment within documentation of 00019 said product would be appreciated but is not required. 00020 00021 2. Altered source versions must be plainly marked as such, and must 00022 not be misrepresented as being the original software. 00023 00024 3. This notice may not be removed or altered from any distribution 00025 of the source. 00026 00027 00028 @version Initial version, June 2004 00029 @author Kris 00030 00031 00032 *******************************************************************************/ 00033 00034 00035 module mango.io.model.IBitBucket; 00036 00037 /****************************************************************************** 00038 00039 IBitBucket implements a simple mechanism to store and recover a 00040 large quantity of data for the duration of the hosting process. 00041 It is intended to act as a local-cache for a remote data-source, 00042 or as a spillover area for large in-memory cache instances. 00043 00044 Note that any and all stored data is rendered invalid the moment 00045 an IBucket object is garbage-collected. 00046 00047 All index keys must be unique. Writing to an IBitBucket with an 00048 existing key will overwrite any previous content. 00049 00050 ******************************************************************************/ 00051 00052 interface IBitBucket 00053 { 00054 /********************************************************************** 00055 00056 Return the record-size in use for this IBitBucket 00057 00058 **********************************************************************/ 00059 00060 int getBufferSize (); 00061 00062 /********************************************************************** 00063 00064 Return the currently populated size of this IBitBucket 00065 00066 **********************************************************************/ 00067 00068 long length (); 00069 00070 /********************************************************************** 00071 00072 Return the serialized data for the provided key. Returns 00073 null if the key was not found. 00074 00075 **********************************************************************/ 00076 00077 void[] get (char[] key); 00078 00079 /********************************************************************** 00080 00081 Remove the provided key from this IBitBucket. 00082 00083 **********************************************************************/ 00084 00085 void remove (char[] key); 00086 00087 /********************************************************************** 00088 00089 Write a serialized block of data, and associate it with 00090 the provided key. All keys must be unique, and it is the 00091 responsibility of the programmer to ensure this. Reusing 00092 an existing key will overwrite previous data. 00093 00094 **********************************************************************/ 00095 00096 void put (char[] key, void[] data); 00097 } 00098 00099