UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'pn8B5SMNonQPTjaNWhfRtf+A8IlidFnApYoEj+SHuV8='
WHERE
key_id = '3cac5f5aaaf5220ec130ff98ce497a75bfab0ccd96ae2e89c6359ddfcb2df8e3'
AND (
token = 'pn8B5SMNonQPTjaNWhfRtf+A8IlidFnApYoEj+SHuV8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)