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