UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'P74jGKG7Rwq2QXYBErgXIAPVvcKpHBDFWSau5SYXmd8='
WHERE
key_id = 'c8a3867c471eebfdd2319e9c9cc66acda5074874e74656b8403c6aca17839943'
AND (
token = 'P74jGKG7Rwq2QXYBErgXIAPVvcKpHBDFWSau5SYXmd8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)