Comments (11)
Make sense to create a set
like queue for your use case.
How is your data? Is it hashable?
from persist-queue.
from persist-queue.
Did you use the file based queue or sqlite based queue?
On my first thought, storing the hash value in sqlite as a column is possible, we can check the uniqueness via SQL, but for filed based queue, no idea for now.
Do you have any idea?
from persist-queue.
from persist-queue.
from persist-queue.
That's a good news.
A set
like queue can be useful in many cases. I do support adding this:
- it can be a new queue, say it's
SetQueue
, we can optimize it on demand - either, doing as you mentioned.
Although, I prefer the first one, the second option is also welcome.
Do you mind sending out the PR for either solution?
Thanks
Peter
from persist-queue.
This works for me but can't fully test right now.
class UniqueQ(persistqueue.SQLiteQueue):
_TABLE_NAME = 'unique_queue'
_SQL_CREATE = ('CREATE TABLE IF NOT EXISTS {table_name} ('
'{key_column} INTEGER PRIMARY KEY AUTOINCREMENT, '
'data BLOB, timestamp FLOAT, UNIQUE (data))')
def put(self, item):
obj = pickle.dumps(item)
try:
self._insert_into(obj, _time.time())
except sqlite3.IntegrityError:
#print("UNIQUE constraint failed")
pass
else:
self.total += 1
self.put_event.set()
from persist-queue.
Looks fine for me, but need to add some test to cover this.
To create PR, please follow below steps:
- fork this project.
- clone your forked project to local.
- create a new branch, say
unique_queue
, then begin to make changes and commit. git push origin unique_queue
.- then your can create the PR based your branch by clicking the button
New pull request
on this page.
from persist-queue.
@delica1 Do you meet any obstacle for the patch:)
from persist-queue.
from persist-queue.
Fixed in PR: #41
from persist-queue.
Related Issues (20)
- qsize not changing HOT 1
- pypi release HOT 3
- mySQL db HOT 10
- SQLite objects created in a thread can only be used in that same thread HOT 2
- File is not getting cleared after get() function HOT 13
- Connection not die after kill signal. HOT 1
- Queue gets corrupted after power cut HOT 9
- sqlite vacuum not working HOT 8
- Queue items not removed after each get() HOT 3
- Priority queue HOT 4
- What if data is already serialized HOT 2
- What if data is already serialized Part II ? HOT 1
- Get() hangs when used with pqid HOT 1
- FILOSQLiteAckQueue is not exported from __init__ HOT 2
- AttributeError: module 'persistqueue' has no attribute 'MySQLQueue' HOT 3
- [BUG] "No sqlite3 module found, sqlite3 based queues are not available" during load, despite sqlite3 being present... and also works despite? HOT 3
- Error while get queue element by id
- Feature Request: allow `before` and `after` controls for `put` to fine tune placement within queue
- Feature Request: Add separate metadata block from ID
- Provide async api
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from persist-queue.