Aggiunto il metodo zap alle cache RW

Aggiunto i costruttori basati su file* per le cache generiche e delle statistiche


git-svn-id: svn://10.65.10.50/trunk@5359 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
augusto 1997-10-14 07:48:10 +00:00
parent 4a0695a363
commit 466c5c81c8
2 changed files with 29 additions and 3 deletions

View File

@ -729,6 +729,14 @@ THash_object * TRWrecord_cache::get_some_obj()
return o; return o;
} }
TRWrecord_cache::TRWrecord_cache(TLocalisamfile *f, int key, bool lock)
:TRecord_cache(f,key)
{
if (lock)
file().lock();
}
TRWrecord_cache::TRWrecord_cache(int num, int key, bool lock) TRWrecord_cache::TRWrecord_cache(int num, int key, bool lock)
:TRecord_cache(num,key) :TRecord_cache(num,key)
{ {
@ -736,6 +744,7 @@ TRWrecord_cache::TRWrecord_cache(int num, int key, bool lock)
file().lock(); file().lock();
} }
TRWrecord_cache::~TRWrecord_cache() TRWrecord_cache::~TRWrecord_cache()
{ {
flush(); flush();
@ -757,7 +766,21 @@ const TString & TStat_cache::getkey2discard()
return o->key(); return o->key();
} }
TStat_cache ::TStat_cache (bool lock): TStat_cache::TStat_cache (TLocalisamfile *f, bool lock):
TRWrecord_cache( LF_SVSTAT,1,lock) TRWrecord_cache( f,1,lock)
{ {
} }
// azzera la cache e distrugge il file!
void TStat_cache::zap()
{
clear();
int err=NOERR;
while (err==NOERR)
{
err=file().first();
if (err==NOERR)
err=file().remove();
}
}

View File

@ -125,6 +125,7 @@ public:
void clear(); void clear();
void flush(); void flush();
TRWrecord_cache(TLocalisamfile *f, int key = 1, bool lock=FALSE);
TRWrecord_cache(int num, int key = 1, bool lock=FALSE); TRWrecord_cache(int num, int key = 1, bool lock=FALSE);
TRWrecord_cache(const char* table, int key = 1, bool lock=FALSE); TRWrecord_cache(const char* table, int key = 1, bool lock=FALSE);
virtual ~TRWrecord_cache() ; virtual ~TRWrecord_cache() ;
@ -135,9 +136,11 @@ class TStat_cache : public TRWrecord_cache
protected: protected:
virtual const TString & getkey2discard(); virtual const TString & getkey2discard();
public: public:
TStat_cache (bool lock=FALSE); TStat_cache (TLocalisamfile &f, bool lock=FALSE);
TStat_cache (TLocalisamfile *f, bool lock=FALSE);
virtual ~TStat_cache() virtual ~TStat_cache()
{} {}
void zap();
}; };
#endif #endif