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