UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'mi/47CMnugPEaOjcKRjdsFGjiZo7mLHAodKMhuj04pA='
WHERE
key_id = 'ea8eba2490d9050e90a43cce1007469a4bab804f774d651f75e0b4c1e4c4161a'
AND (
token = 'mi/47CMnugPEaOjcKRjdsFGjiZo7mLHAodKMhuj04pA='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)